Switch Flutter to //lib/fidl (flutter/engine#3206)

This commit is contained in:
Adam Barth
2016-11-07 15:51:42 -08:00
committed by GitHub
parent b09b35cc06
commit 1d7337b4d8
11 changed files with 17 additions and 196 deletions

View File

@@ -47,7 +47,7 @@ def main():
'--packages=%s' % args.packages,
'--snapshot=%s' % args.snapshot,
'--output-file=%s' % args.output_file,
'--header=#!mojo mojo:flutter_content_handler',
'--header=#!fuchsia file:///system/apps/flutter_runner',
], env=env, cwd=args.app_dir)
return result

View File

@@ -55,8 +55,8 @@ source_set("flow") {
"layers/child_scene_layer.h",
"texture_image_none.cc",
]
deps += [
"//apps/mozart/services/composition/interfaces",
public_deps = [
"//apps/mozart/services/composition",
]
} else {
sources += [

View File

@@ -7,9 +7,9 @@
namespace flow {
namespace {
mojo::TransformPtr GetTransformFromSkMatrix(const SkMatrix& input) {
mozart::TransformPtr GetTransformFromSkMatrix(const SkMatrix& input) {
// Expand 3x3 to 4x4.
auto output = mojo::Transform::New();
auto output = mozart::Transform::New();
output->matrix.resize(16u);
output->matrix[0] = input[0];
output->matrix[1] = input[1];
@@ -27,7 +27,7 @@ mojo::TransformPtr GetTransformFromSkMatrix(const SkMatrix& input) {
output->matrix[13] = input[7];
output->matrix[14] = 0.f;
output->matrix[15] = input[8];
return output.Pass();
return output;
}
// TODO(abarth): We need to figure out how to allocate these ids sensibly.
@@ -58,17 +58,17 @@ void ChildSceneLayer::UpdateScene(mozart::SceneUpdate* update,
child_resource->set_scene(mozart::SceneResource::New());
child_resource->get_scene()->scene_token = mozart::SceneToken::New();
child_resource->get_scene()->scene_token->value = scene_token_;
update->resources.insert(id, child_resource.Pass());
update->resources.insert(id, std::move(child_resource));
auto child_node = mozart::Node::New();
child_node->op = mozart::NodeOp::New();
child_node->op->set_scene(mozart::SceneNodeOp::New());
child_node->op->get_scene()->scene_resource_id = id;
child_node->content_clip = mojo::RectF::New();
child_node->content_clip = mozart::RectF::New();
child_node->content_clip->width = physical_size_.width();
child_node->content_clip->height = physical_size_.height();
child_node->content_transform = GetTransformFromSkMatrix(transform_);
update->nodes.insert(id, child_node.Pass());
update->nodes.insert(id, std::move(child_node));
container->child_node_ids.push_back(id);
}

View File

@@ -6,7 +6,7 @@
#define FLUTTER_FLOW_LAYERS_CHILD_SCENE_LAYER_H_
#include "flutter/flow/layers/layer.h"
#include "apps/mozart/services/composition/interfaces/scenes.mojom.h"
#include "apps/mozart/services/composition/scenes.fidl.h"
namespace flow {

View File

@@ -5,7 +5,6 @@
source_set("glue") {
sources = [
"stack_trace.h",
"thread.h",
"trace_event.h",
]
@@ -15,27 +14,13 @@ source_set("glue") {
if (is_fuchsia) {
sources += [
"drain_data_pipe_job.h",
"drain_data_pipe_job_fuchsia.cc",
"stack_trace_fuchsia.cc",
"thread_fuchsia.cc",
]
deps += [
"//lib/mtl",
"//mojo/public/cpp/environment",
"//mojo/public/cpp/system",
]
public_deps = [
"//lib/trace_event",
]
} else {
sources += [
"stack_trace_base.cc",
"task_runner_adaptor.cc",
"task_runner_adaptor.h",
"thread_base.cc",
]
deps += [

View File

@@ -1,35 +0,0 @@
// Copyright 2016 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 FLUTTER_GLU_DRAIN_DATA_PIPE_JOB_H_
#define FLUTTER_GLU_DRAIN_DATA_PIPE_JOB_H_
#include <functional>
#include <memory>
#include <vector>
#include "lib/ftl/macros.h"
#include "mojo/public/cpp/system/data_pipe.h"
namespace glue {
class DrainDataPipeJob {
public:
using ResultCallback = std::function<void(std::vector<uint8_t>)>;
DrainDataPipeJob(mojo::ScopedDataPipeConsumerHandle handle,
const ResultCallback& callback);
~DrainDataPipeJob();
private:
class JobImpl;
std::unique_ptr<JobImpl> impl_;
FTL_DISALLOW_COPY_AND_ASSIGN(DrainDataPipeJob);
};
} // namespace glue
#endif // FLUTTER_GLU_DRAIN_DATA_PIPE_JOB_H_

View File

@@ -1,45 +0,0 @@
// Copyright 2016 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.
#include "flutter/glue/drain_data_pipe_job.h"
#include <utility>
#include "lib/mtl/data_pipe/data_pipe_drainer.h"
using mtl::DataPipeDrainer;
namespace glue {
class DrainDataPipeJob::JobImpl : public DataPipeDrainer::Client {
public:
explicit JobImpl(mojo::ScopedDataPipeConsumerHandle handle,
const ResultCallback& callback)
: callback_(callback), drainer_(this) {
drainer_.Start(std::move(handle));
}
private:
// mojo::common::DataPipeDrainer::Client
void OnDataAvailable(const void* data, size_t num_bytes) override {
const uint8_t* bytes = static_cast<const uint8_t*>(data);
buffer_.insert(buffer_.end(), bytes, bytes + num_bytes);
}
void OnDataComplete() override { callback_(std::move(buffer_)); }
std::vector<uint8_t> buffer_;
ResultCallback callback_;
DataPipeDrainer drainer_;
FTL_DISALLOW_COPY_AND_ASSIGN(JobImpl);
};
DrainDataPipeJob::DrainDataPipeJob(mojo::ScopedDataPipeConsumerHandle handle,
const ResultCallback& callback)
: impl_(new JobImpl(std::move(handle), callback)) {}
DrainDataPipeJob::~DrainDataPipeJob() {}
} // namespace glue

View File

@@ -1,34 +0,0 @@
// Copyright 2016 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 FLUTTER_GLU_THREAD_H_
#define FLUTTER_GLU_THREAD_H_
#include <memory>
#include "lib/ftl/tasks/task_runner.h"
namespace glue {
class Thread {
public:
Thread(std::string name);
~Thread();
bool Start();
const ftl::RefPtr<ftl::TaskRunner>& task_runner() { return task_runner_; }
private:
class ThreadImpl;
std::unique_ptr<ThreadImpl> impl_;
ftl::RefPtr<ftl::TaskRunner> task_runner_;
FTL_DISALLOW_COPY_AND_ASSIGN(Thread);
};
} // namespace glue
#endif // FLUTTER_GLU_THREAD_H_

View File

@@ -1,29 +0,0 @@
// Copyright 2016 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.
#include "flutter/glue/thread.h"
#include <utility>
#include "base/threading/thread.h"
#include "flutter/glue/task_runner_adaptor.h"
namespace glue {
class Thread::ThreadImpl : public base::Thread {
public:
ThreadImpl(std::string name) : base::Thread(std::move(name)) {}
};
Thread::Thread(std::string name) : impl_(new ThreadImpl(name)) {}
Thread::~Thread() {}
bool Thread::Start() {
bool result = impl_->Start();
task_runner_ = ftl::MakeRefCounted<TaskRunnerAdaptor>(impl_->task_runner());
return result;
}
} // namespace glue

View File

@@ -1,27 +0,0 @@
// Copyright 2016 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.
#include "flutter/glue/thread.h"
#include <utility>
#include "lib/mtl/threading/create_thread.h"
namespace glue {
class Thread::ThreadImpl {
public:
std::thread thread_;
};
Thread::Thread(std::string name) : impl_(new ThreadImpl()) {}
Thread::~Thread() {}
bool Thread::Start() {
impl_->thread_ = mtl::CreateThread(&task_runner_);
return true;
}
} // namespace glue

View File

@@ -3,7 +3,13 @@
// found in the LICENSE file.
#if defined(__Fuchsia__)
#include "lib/trace_event/macros.h"
#define TRACE_EVENT0(a, b)
#define TRACE_EVENT1(a, b, c, d)
#define TRACE_EVENT2(a, b, c, d, e, f)
#define TRACE_EVENT_ASYNC_BEGIN0(a, b, c)
#define TRACE_EVENT_ASYNC_END0(a, b, c)
#define TRACE_EVENT_ASYNC_BEGIN1(a, b, c, d, e)
#define TRACE_EVENT_ASYNC_END1(a, b, c, d, e)
#else
#include "base/trace_event/trace_event.h"
#endif // defined(__Fuchsia__)