From 9586997a027252be4ad7d1df996010e2f4e1de09 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 1 Aug 2016 15:11:56 -0700 Subject: [PATCH] Port //flow to //lib/ftl (flutter/engine#2847) This patch removes almost all //base dependency of //flow. The only dependency left is on tracing. --- engine/src/flutter/.gitignore | 1 + engine/src/flutter/flow/BUILD.gn | 1 + engine/src/flutter/flow/checkerboard.cc | 3 +- engine/src/flutter/flow/compositor_context.cc | 15 +++--- engine/src/flutter/flow/compositor_context.h | 7 ++- engine/src/flutter/flow/instrumentation.cc | 54 +++++++++++-------- engine/src/flutter/flow/instrumentation.h | 24 +++++---- .../flow/layers/backdrop_filter_layer.cc | 10 ++-- .../flow/layers/backdrop_filter_layer.h | 2 +- .../flutter/flow/layers/child_scene_layer.cc | 6 +-- .../flutter/flow/layers/child_scene_layer.h | 2 +- .../flutter/flow/layers/clip_path_layer.cc | 6 +-- .../src/flutter/flow/layers/clip_path_layer.h | 2 +- .../flutter/flow/layers/clip_rect_layer.cc | 6 +-- .../src/flutter/flow/layers/clip_rect_layer.h | 2 +- .../flutter/flow/layers/clip_rrect_layer.cc | 6 +-- .../flutter/flow/layers/clip_rrect_layer.h | 2 +- .../flutter/flow/layers/color_filter_layer.cc | 6 +-- .../flutter/flow/layers/color_filter_layer.h | 2 +- .../flutter/flow/layers/container_layer.cc | 6 +-- .../src/flutter/flow/layers/container_layer.h | 2 +- engine/src/flutter/flow/layers/layer.cc | 15 ++---- engine/src/flutter/flow/layers/layer.h | 10 ++-- engine/src/flutter/flow/layers/layer_tree.cc | 15 ++---- engine/src/flutter/flow/layers/layer_tree.h | 15 +++--- .../src/flutter/flow/layers/opacity_layer.cc | 6 +-- .../src/flutter/flow/layers/opacity_layer.h | 2 +- .../flow/layers/performance_overlay_layer.cc | 30 +++++------ .../flow/layers/performance_overlay_layer.h | 4 +- .../src/flutter/flow/layers/picture_layer.cc | 4 +- .../src/flutter/flow/layers/picture_layer.h | 2 +- .../flutter/flow/layers/shader_mask_layer.cc | 6 +-- .../flutter/flow/layers/shader_mask_layer.h | 6 +-- .../flutter/flow/layers/transform_layer.cc | 6 +-- .../src/flutter/flow/layers/transform_layer.h | 2 +- engine/src/flutter/flow/open_gl.h | 2 +- engine/src/flutter/flow/raster_cache.cc | 2 +- engine/src/flutter/flow/raster_cache.h | 10 ++-- engine/src/flutter/flow/texture_image.h | 1 - 39 files changed, 139 insertions(+), 164 deletions(-) diff --git a/engine/src/flutter/.gitignore b/engine/src/flutter/.gitignore index 29ab06539f5..448971caf7a 100644 --- a/engine/src/flutter/.gitignore +++ b/engine/src/flutter/.gitignore @@ -25,6 +25,7 @@ Thumbs.db /build/linux/bin/eu-strip /buildtools/ /dart/ +/lib/ /mojo/devtools/ /mojo/public/ /native_client/ diff --git a/engine/src/flutter/flow/BUILD.gn b/engine/src/flutter/flow/BUILD.gn index 560d960f499..aa701a2c1ee 100644 --- a/engine/src/flutter/flow/BUILD.gn +++ b/engine/src/flutter/flow/BUILD.gn @@ -47,6 +47,7 @@ source_set("flow") { deps = [ "//base", + "//lib/ftl", "//mojo/services/gfx/composition/interfaces", "//mojo/skia", "//skia", diff --git a/engine/src/flutter/flow/checkerboard.cc b/engine/src/flutter/flow/checkerboard.cc index a420e309637..b88c0d1b147 100644 --- a/engine/src/flutter/flow/checkerboard.cc +++ b/engine/src/flutter/flow/checkerboard.cc @@ -8,7 +8,8 @@ namespace flow { -static sk_sp CreateCheckerboardShader(SkColor c1, SkColor c2, +static sk_sp CreateCheckerboardShader(SkColor c1, + SkColor c2, int size) { SkBitmap bm; bm.allocN32Pixels(2 * size, 2 * size); diff --git a/engine/src/flutter/flow/compositor_context.cc b/engine/src/flutter/flow/compositor_context.cc index 5dbc25f7958..7c1b75e57fb 100644 --- a/engine/src/flutter/flow/compositor_context.cc +++ b/engine/src/flutter/flow/compositor_context.cc @@ -4,16 +4,13 @@ #include "flow/compositor_context.h" -#include "base/logging.h" #include "third_party/skia/include/core/SkCanvas.h" namespace flow { -CompositorContext::CompositorContext() { -} +CompositorContext::CompositorContext() {} -CompositorContext::~CompositorContext() { -} +CompositorContext::~CompositorContext() {} void CompositorContext::BeginFrame(ScopedFrame& frame, bool enable_instrumentation) { @@ -32,7 +29,9 @@ void CompositorContext::EndFrame(ScopedFrame& frame, } CompositorContext::ScopedFrame CompositorContext::AcquireFrame( - GrContext* gr_context, SkCanvas& canvas, bool instrumentation_enabled) { + GrContext* gr_context, + SkCanvas& canvas, + bool instrumentation_enabled) { return ScopedFrame(*this, gr_context, canvas, instrumentation_enabled); } @@ -40,7 +39,9 @@ CompositorContext::ScopedFrame::ScopedFrame(CompositorContext& context, GrContext* gr_context, SkCanvas& canvas, bool instrumentation_enabled) - : context_(context), gr_context_(gr_context), canvas_(&canvas), + : context_(context), + gr_context_(gr_context), + canvas_(&canvas), instrumentation_enabled_(instrumentation_enabled) { context_.BeginFrame(*this, instrumentation_enabled_); } diff --git a/engine/src/flutter/flow/compositor_context.h b/engine/src/flutter/flow/compositor_context.h index 4ac7d517455..8ede656d55e 100644 --- a/engine/src/flutter/flow/compositor_context.h +++ b/engine/src/flutter/flow/compositor_context.h @@ -8,10 +8,9 @@ #include #include -#include "base/macros.h" -#include "base/logging.h" #include "flow/instrumentation.h" #include "flow/raster_cache.h" +#include "lib/ftl/macros.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkPictureRecorder.h" @@ -41,7 +40,7 @@ class CompositorContext { friend class CompositorContext; - DISALLOW_COPY_AND_ASSIGN(ScopedFrame); + FTL_DISALLOW_COPY_AND_ASSIGN(ScopedFrame); }; CompositorContext(); @@ -68,7 +67,7 @@ class CompositorContext { void BeginFrame(ScopedFrame& frame, bool enable_instrumentation); void EndFrame(ScopedFrame& frame, bool enable_instrumentation); - DISALLOW_COPY_AND_ASSIGN(CompositorContext); + FTL_DISALLOW_COPY_AND_ASSIGN(CompositorContext); }; } // namespace flow diff --git a/engine/src/flutter/flow/instrumentation.cc b/engine/src/flutter/flow/instrumentation.cc index bdabde74de6..f5e7228c233 100644 --- a/engine/src/flutter/flow/instrumentation.cc +++ b/engine/src/flutter/flow/instrumentation.cc @@ -13,26 +13,26 @@ namespace flow { static const size_t kMaxSamples = 120; static const size_t kMaxFrameMarkers = 8; -Stopwatch::Stopwatch() : start_(base::TimeTicks::Now()), current_sample_(0) { - const base::TimeDelta delta; +Stopwatch::Stopwatch() : start_(ftl::TimePoint::Now()), current_sample_(0) { + const ftl::TimeDelta delta; laps_.resize(kMaxSamples, delta); } void Stopwatch::Start() { - start_ = base::TimeTicks::Now(); + start_ = ftl::TimePoint::Now(); current_sample_ = (current_sample_ + 1) % kMaxSamples; } void Stopwatch::Stop() { - laps_[current_sample_] = base::TimeTicks::Now() - start_; + laps_[current_sample_] = ftl::TimePoint::Now() - start_; } -void Stopwatch::SetLapTime(const base::TimeDelta& delta) { +void Stopwatch::SetLapTime(const ftl::TimeDelta& delta) { current_sample_ = (current_sample_ + 1) % kMaxSamples; laps_[current_sample_] = delta; } -const base::TimeDelta& Stopwatch::LastLap() const { +const ftl::TimeDelta& Stopwatch::LastLap() const { return laps_[(current_sample_ - 1) % kMaxSamples]; } @@ -40,15 +40,16 @@ static inline constexpr double UnitFrameInterval(double frame_time_ms) { return frame_time_ms * 60.0 * 1e-3; } -static inline double UnitHeight(double frame_time_ms, double max_unit_interval) { +static inline double UnitHeight(double frame_time_ms, + double max_unit_interval) { double unitHeight = UnitFrameInterval(frame_time_ms) / max_unit_interval; if (unitHeight > 1.0) unitHeight = 1.0; return unitHeight; } -base::TimeDelta Stopwatch::MaxDelta() const { - base::TimeDelta max_delta; +ftl::TimeDelta Stopwatch::MaxDelta() const { + ftl::TimeDelta max_delta; for (size_t i = 0; i < kMaxSamples; i++) { if (laps_[i] > max_delta) max_delta = laps_[i]; @@ -71,7 +72,8 @@ void Stopwatch::Visualize(SkCanvas& canvas, const SkRect& rect) const { const SkScalar bottom = y + height; const SkScalar right = x + width; - // Scale the graph to show frame times up to those that are 3 times the frame time. + // Scale the graph to show frame times up to those that are 3 times the frame + // time. const double max_interval = kOneFrameMS * 3.0; const double max_unit_interval = UnitFrameInterval(max_interval); @@ -82,20 +84,26 @@ void Stopwatch::Visualize(SkCanvas& canvas, const SkRect& rect) const { const double sample_margin_unit_width = sample_unit_width / 6.0; const double sample_margin_width = width * sample_margin_unit_width; path.moveTo(x, bottom); - path.lineTo(x, y + height * (1.0 - UnitHeight(laps_[0].InMillisecondsF(), + path.lineTo(x, y + + height * (1.0 - UnitHeight(laps_[0].ToMillisecondsF(), max_unit_interval))); double unit_x; double unit_next_x = 0.0; for (size_t i = 0; i < kMaxSamples; i += 1) { unit_x = unit_next_x; unit_next_x = (static_cast(i + 1) / kMaxSamples); - const double sample_y = y + height * (1.0 - UnitHeight(laps_[i].InMillisecondsF(), - max_unit_interval)); + const double sample_y = + y + + height * + (1.0 - UnitHeight(laps_[i].ToMillisecondsF(), max_unit_interval)); path.lineTo(x + width * unit_x + sample_margin_width, sample_y); path.lineTo(x + width * unit_next_x - sample_margin_width, sample_y); } - path.lineTo(right, y + height * (1.0 - UnitHeight(laps_[kMaxSamples - 1].InMillisecondsF(), - max_unit_interval))); + path.lineTo( + right, + y + + height * (1.0 - UnitHeight(laps_[kMaxSamples - 1].ToMillisecondsF(), + max_unit_interval))); path.lineTo(right, bottom); path.close(); @@ -104,7 +112,7 @@ void Stopwatch::Visualize(SkCanvas& canvas, const SkRect& rect) const { canvas.drawPath(path, paint); // Draw horizontal markers. - paint.setStrokeWidth(0); // hairline + paint.setStrokeWidth(0); // hairline paint.setStyle(SkPaint::Style::kStroke_Style); paint.setColor(0xCC000000); @@ -117,7 +125,8 @@ void Stopwatch::Visualize(SkCanvas& canvas, const SkRect& rect) const { if (frame_marker_count > kMaxFrameMarkers) frame_marker_count = 1; - for (size_t frame_index = 0; frame_index < frame_marker_count; frame_index++) { + for (size_t frame_index = 0; frame_index < frame_marker_count; + frame_index++) { const double frame_height = height * (1.0 - (UnitFrameInterval((frame_index + 1) * kOneFrameMS) / max_unit_interval)); @@ -129,16 +138,19 @@ void Stopwatch::Visualize(SkCanvas& canvas, const SkRect& rect) const { // We paint it over the current frame, not after it, because when we // paint this we don't yet have all the times for the current frame. paint.setStyle(SkPaint::Style::kFill_Style); - if (UnitFrameInterval(LastLap().InMillisecondsF()) > 1.0) { + if (UnitFrameInterval(LastLap().ToMillisecondsF()) > 1.0) { // budget exceeded paint.setColor(SK_ColorRED); } else { // within budget paint.setColor(SK_ColorGREEN); } - double sample_x = x + width * (static_cast(current_sample_) / kMaxSamples) - - sample_margin_width; - canvas.drawRectCoords(sample_x, y, sample_x + width * sample_unit_width + sample_margin_width * 2, bottom, paint); + double sample_x = + x + width * (static_cast(current_sample_) / kMaxSamples) - + sample_margin_width; + canvas.drawRectCoords(sample_x, y, sample_x + width * sample_unit_width + + sample_margin_width * 2, + bottom, paint); } Stopwatch::~Stopwatch() = default; diff --git a/engine/src/flutter/flow/instrumentation.h b/engine/src/flutter/flow/instrumentation.h index 84f4e3616fb..eb3c89d20c2 100644 --- a/engine/src/flutter/flow/instrumentation.h +++ b/engine/src/flutter/flow/instrumentation.h @@ -6,8 +6,10 @@ #define FLOW_INSTRUMENTATION_H_ #include -#include "base/macros.h" -#include "base/time/time.h" + +#include "lib/ftl/macros.h" +#include "lib/ftl/time/time_delta.h" +#include "lib/ftl/time/time_point.h" #include "third_party/skia/include/core/SkCanvas.h" namespace flow { @@ -27,26 +29,26 @@ class Stopwatch { private: Stopwatch& stopwatch_; - DISALLOW_COPY_AND_ASSIGN(ScopedLap); + FTL_DISALLOW_COPY_AND_ASSIGN(ScopedLap); }; explicit Stopwatch(); ~Stopwatch(); - const base::TimeDelta& LastLap() const; - base::TimeDelta CurrentLap() const { return base::TimeTicks::Now() - start_; } - base::TimeDelta MaxDelta() const; + const ftl::TimeDelta& LastLap() const; + ftl::TimeDelta CurrentLap() const { return ftl::TimePoint::Now() - start_; } + ftl::TimeDelta MaxDelta() const; void Visualize(SkCanvas& canvas, const SkRect& rect) const; void Start(); void Stop(); - void SetLapTime(const base::TimeDelta& delta); + void SetLapTime(const ftl::TimeDelta& delta); private: - base::TimeTicks start_; - std::vector laps_; + ftl::TimePoint start_; + std::vector laps_; size_t current_sample_; - DISALLOW_COPY_AND_ASSIGN(Stopwatch); + FTL_DISALLOW_COPY_AND_ASSIGN(Stopwatch); }; class Counter { @@ -60,7 +62,7 @@ class Counter { private: size_t count_; - DISALLOW_COPY_AND_ASSIGN(Counter); + FTL_DISALLOW_COPY_AND_ASSIGN(Counter); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/backdrop_filter_layer.cc b/engine/src/flutter/flow/layers/backdrop_filter_layer.cc index 84ff9e6b0aa..f267c5edf03 100644 --- a/engine/src/flutter/flow/layers/backdrop_filter_layer.cc +++ b/engine/src/flutter/flow/layers/backdrop_filter_layer.cc @@ -8,17 +8,15 @@ namespace flow { -BackdropFilterLayer::BackdropFilterLayer() { -} +BackdropFilterLayer::BackdropFilterLayer() {} -BackdropFilterLayer::~BackdropFilterLayer() { -} +BackdropFilterLayer::~BackdropFilterLayer() {} void BackdropFilterLayer::Paint(PaintContext& context) { TRACE_EVENT0("flutter", "BackdropFilterLayer::Paint"); SkAutoCanvasRestore save(&context.canvas, false); - context.canvas.saveLayer(SkCanvas::SaveLayerRec{ - &paint_bounds(), nullptr, filter_.get(), 0}); + context.canvas.saveLayer( + SkCanvas::SaveLayerRec{&paint_bounds(), nullptr, filter_.get(), 0}); PaintChildren(context); } diff --git a/engine/src/flutter/flow/layers/backdrop_filter_layer.h b/engine/src/flutter/flow/layers/backdrop_filter_layer.h index 74a8461b48c..e16d82b5987 100644 --- a/engine/src/flutter/flow/layers/backdrop_filter_layer.h +++ b/engine/src/flutter/flow/layers/backdrop_filter_layer.h @@ -22,7 +22,7 @@ class BackdropFilterLayer : public ContainerLayer { private: sk_sp filter_; - DISALLOW_COPY_AND_ASSIGN(BackdropFilterLayer); + FTL_DISALLOW_COPY_AND_ASSIGN(BackdropFilterLayer); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/child_scene_layer.cc b/engine/src/flutter/flow/layers/child_scene_layer.cc index 84ad5c030c3..3ef8ff2f744 100644 --- a/engine/src/flutter/flow/layers/child_scene_layer.cc +++ b/engine/src/flutter/flow/layers/child_scene_layer.cc @@ -11,11 +11,9 @@ namespace flow { // TODO(abarth): We need to figure out how to allocate these ids sensibly. static uint32_t next_id = 10; -ChildSceneLayer::ChildSceneLayer() : device_pixel_ratio_(1.0f) { -} +ChildSceneLayer::ChildSceneLayer() : device_pixel_ratio_(1.0f) {} -ChildSceneLayer::~ChildSceneLayer() { -} +ChildSceneLayer::~ChildSceneLayer() {} void ChildSceneLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { transform_ = matrix; diff --git a/engine/src/flutter/flow/layers/child_scene_layer.h b/engine/src/flutter/flow/layers/child_scene_layer.h index 7a573728c1e..d88cac40170 100644 --- a/engine/src/flutter/flow/layers/child_scene_layer.h +++ b/engine/src/flutter/flow/layers/child_scene_layer.h @@ -41,7 +41,7 @@ class ChildSceneLayer : public Layer { mojo::gfx::composition::SceneTokenPtr scene_token_; SkMatrix transform_; - DISALLOW_COPY_AND_ASSIGN(ChildSceneLayer); + FTL_DISALLOW_COPY_AND_ASSIGN(ChildSceneLayer); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/clip_path_layer.cc b/engine/src/flutter/flow/layers/clip_path_layer.cc index 4ebc4578ecc..fa1622a539d 100644 --- a/engine/src/flutter/flow/layers/clip_path_layer.cc +++ b/engine/src/flutter/flow/layers/clip_path_layer.cc @@ -6,11 +6,9 @@ namespace flow { -ClipPathLayer::ClipPathLayer() { -} +ClipPathLayer::ClipPathLayer() {} -ClipPathLayer::~ClipPathLayer() { -} +ClipPathLayer::~ClipPathLayer() {} void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { PrerollChildren(context, matrix); diff --git a/engine/src/flutter/flow/layers/clip_path_layer.h b/engine/src/flutter/flow/layers/clip_path_layer.h index 70cd6e58940..17838ed2272 100644 --- a/engine/src/flutter/flow/layers/clip_path_layer.h +++ b/engine/src/flutter/flow/layers/clip_path_layer.h @@ -23,7 +23,7 @@ class ClipPathLayer : public ContainerLayer { private: SkPath clip_path_; - DISALLOW_COPY_AND_ASSIGN(ClipPathLayer); + FTL_DISALLOW_COPY_AND_ASSIGN(ClipPathLayer); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/clip_rect_layer.cc b/engine/src/flutter/flow/layers/clip_rect_layer.cc index 3fe957ccd71..7c75644d9a5 100644 --- a/engine/src/flutter/flow/layers/clip_rect_layer.cc +++ b/engine/src/flutter/flow/layers/clip_rect_layer.cc @@ -6,11 +6,9 @@ namespace flow { -ClipRectLayer::ClipRectLayer() { -} +ClipRectLayer::ClipRectLayer() {} -ClipRectLayer::~ClipRectLayer() { -} +ClipRectLayer::~ClipRectLayer() {} void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { PrerollChildren(context, matrix); diff --git a/engine/src/flutter/flow/layers/clip_rect_layer.h b/engine/src/flutter/flow/layers/clip_rect_layer.h index 6804a657cae..b23e2721b51 100644 --- a/engine/src/flutter/flow/layers/clip_rect_layer.h +++ b/engine/src/flutter/flow/layers/clip_rect_layer.h @@ -23,7 +23,7 @@ class ClipRectLayer : public ContainerLayer { private: SkRect clip_rect_; - DISALLOW_COPY_AND_ASSIGN(ClipRectLayer); + FTL_DISALLOW_COPY_AND_ASSIGN(ClipRectLayer); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/clip_rrect_layer.cc b/engine/src/flutter/flow/layers/clip_rrect_layer.cc index b804ebf04b4..4ec794efe08 100644 --- a/engine/src/flutter/flow/layers/clip_rrect_layer.cc +++ b/engine/src/flutter/flow/layers/clip_rrect_layer.cc @@ -6,11 +6,9 @@ namespace flow { -ClipRRectLayer::ClipRRectLayer() { -} +ClipRRectLayer::ClipRRectLayer() {} -ClipRRectLayer::~ClipRRectLayer() { -} +ClipRRectLayer::~ClipRRectLayer() {} void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { PrerollChildren(context, matrix); diff --git a/engine/src/flutter/flow/layers/clip_rrect_layer.h b/engine/src/flutter/flow/layers/clip_rrect_layer.h index 336c4417888..21137459a9c 100644 --- a/engine/src/flutter/flow/layers/clip_rrect_layer.h +++ b/engine/src/flutter/flow/layers/clip_rrect_layer.h @@ -23,7 +23,7 @@ class ClipRRectLayer : public ContainerLayer { private: SkRRect clip_rrect_; - DISALLOW_COPY_AND_ASSIGN(ClipRRectLayer); + FTL_DISALLOW_COPY_AND_ASSIGN(ClipRRectLayer); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/color_filter_layer.cc b/engine/src/flutter/flow/layers/color_filter_layer.cc index 57794c74e2c..9abcd62bcc8 100644 --- a/engine/src/flutter/flow/layers/color_filter_layer.cc +++ b/engine/src/flutter/flow/layers/color_filter_layer.cc @@ -6,11 +6,9 @@ namespace flow { -ColorFilterLayer::ColorFilterLayer() { -} +ColorFilterLayer::ColorFilterLayer() {} -ColorFilterLayer::~ColorFilterLayer() { -} +ColorFilterLayer::~ColorFilterLayer() {} void ColorFilterLayer::Paint(PaintContext& context) { TRACE_EVENT0("flutter", "ColorFilterLayer::Paint"); diff --git a/engine/src/flutter/flow/layers/color_filter_layer.h b/engine/src/flutter/flow/layers/color_filter_layer.h index 4dbdf7d8467..05c57085dc4 100644 --- a/engine/src/flutter/flow/layers/color_filter_layer.h +++ b/engine/src/flutter/flow/layers/color_filter_layer.h @@ -27,7 +27,7 @@ class ColorFilterLayer : public ContainerLayer { SkColor color_; SkXfermode::Mode transfer_mode_; - DISALLOW_COPY_AND_ASSIGN(ColorFilterLayer); + FTL_DISALLOW_COPY_AND_ASSIGN(ColorFilterLayer); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/container_layer.cc b/engine/src/flutter/flow/layers/container_layer.cc index 62b4ffc8829..ee29d74d878 100644 --- a/engine/src/flutter/flow/layers/container_layer.cc +++ b/engine/src/flutter/flow/layers/container_layer.cc @@ -6,11 +6,9 @@ namespace flow { -ContainerLayer::ContainerLayer() { -} +ContainerLayer::ContainerLayer() {} -ContainerLayer::~ContainerLayer() { -} +ContainerLayer::~ContainerLayer() {} void ContainerLayer::Add(std::unique_ptr layer) { layer->set_parent(this); diff --git a/engine/src/flutter/flow/layers/container_layer.h b/engine/src/flutter/flow/layers/container_layer.h index 09fc66342d9..37ede5b11f2 100644 --- a/engine/src/flutter/flow/layers/container_layer.h +++ b/engine/src/flutter/flow/layers/container_layer.h @@ -30,7 +30,7 @@ class ContainerLayer : public Layer { private: std::vector> layers_; - DISALLOW_COPY_AND_ASSIGN(ContainerLayer); + FTL_DISALLOW_COPY_AND_ASSIGN(ContainerLayer); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/layer.cc b/engine/src/flutter/flow/layers/layer.cc index 49139525fa4..5b2434745e2 100644 --- a/engine/src/flutter/flow/layers/layer.cc +++ b/engine/src/flutter/flow/layers/layer.cc @@ -8,20 +8,13 @@ namespace flow { -Layer::Layer() - : parent_(nullptr) - , has_paint_bounds_(false) - , paint_bounds_() { -} +Layer::Layer() : parent_(nullptr), has_paint_bounds_(false), paint_bounds_() {} -Layer::~Layer() { -} +Layer::~Layer() {} -void Layer::Preroll(PrerollContext* context, const SkMatrix& matrix) { -} +void Layer::Preroll(PrerollContext* context, const SkMatrix& matrix) {} void Layer::UpdateScene(mojo::gfx::composition::SceneUpdate* update, - mojo::gfx::composition::Node* container) { -} + mojo::gfx::composition::Node* container) {} } // namespace flow diff --git a/engine/src/flutter/flow/layers/layer.h b/engine/src/flutter/flow/layers/layer.h index d322208617e..c85bc97b8b9 100644 --- a/engine/src/flutter/flow/layers/layer.h +++ b/engine/src/flutter/flow/layers/layer.h @@ -8,11 +8,11 @@ #include #include -#include "base/logging.h" -#include "base/macros.h" #include "base/trace_event/trace_event.h" #include "flow/instrumentation.h" #include "flow/raster_cache.h" +#include "lib/ftl/logging.h" +#include "lib/ftl/macros.h" #include "skia/ext/refptr.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkColor.h" @@ -67,7 +67,7 @@ class Layer { bool has_paint_bounds() const { return has_paint_bounds_; } const SkRect& paint_bounds() const { - DCHECK(has_paint_bounds_); + FTL_DCHECK(has_paint_bounds_); return paint_bounds_; } @@ -78,10 +78,10 @@ class Layer { private: ContainerLayer* parent_; - bool has_paint_bounds_; // if false, paint_bounds_ is not valid + bool has_paint_bounds_; // if false, paint_bounds_ is not valid SkRect paint_bounds_; - DISALLOW_COPY_AND_ASSIGN(Layer); + FTL_DISALLOW_COPY_AND_ASSIGN(Layer); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/layer_tree.cc b/engine/src/flutter/flow/layers/layer_tree.cc index 0d4e58b9710..18fe780fc71 100644 --- a/engine/src/flutter/flow/layers/layer_tree.cc +++ b/engine/src/flutter/flow/layers/layer_tree.cc @@ -9,28 +9,23 @@ namespace flow { -LayerTree::LayerTree() : scene_version_(0), rasterizer_tracing_threshold_(0) { -} +LayerTree::LayerTree() : scene_version_(0), rasterizer_tracing_threshold_(0) {} -LayerTree::~LayerTree() { -} +LayerTree::~LayerTree() {} void LayerTree::Raster(CompositorContext::ScopedFrame& frame) { { TRACE_EVENT0("flutter", "LayerTree::Preroll"); Layer::PrerollContext context = { - frame.context().raster_cache(), - frame.gr_context(), - SkRect::MakeEmpty(), + frame.context().raster_cache(), frame.gr_context(), SkRect::MakeEmpty(), }; root_layer_->Preroll(&context, SkMatrix()); } { Layer::PaintContext context = { - frame.canvas(), - frame.context().frame_time(), - frame.context().engine_time(), + frame.canvas(), frame.context().frame_time(), + frame.context().engine_time(), }; TRACE_EVENT0("flutter", "LayerTree::Paint"); root_layer_->Paint(context); diff --git a/engine/src/flutter/flow/layers/layer_tree.h b/engine/src/flutter/flow/layers/layer_tree.h index ef83ce6abb5..30252190cb7 100644 --- a/engine/src/flutter/flow/layers/layer_tree.h +++ b/engine/src/flutter/flow/layers/layer_tree.h @@ -6,12 +6,13 @@ #define FLOW_LAYERS_LAYER_TREE_H_ #include + #include -#include "base/macros.h" -#include "base/time/time.h" #include "flow/compositor_context.h" #include "flow/layers/layer.h" +#include "lib/ftl/macros.h" +#include "lib/ftl/time/time_delta.h" #include "third_party/skia/include/core/SkSize.h" namespace flow { @@ -44,13 +45,11 @@ class LayerTree { scene_version_ = scene_version; } - void set_construction_time(const base::TimeDelta& delta) { + void set_construction_time(const ftl::TimeDelta& delta) { construction_time_ = delta; } - const base::TimeDelta& construction_time() const { - return construction_time_; - } + const ftl::TimeDelta& construction_time() const { return construction_time_; } // The number of frame intervals missed after which the compositor must // trace the rasterized picture to a trace file. Specify 0 to disable all @@ -68,10 +67,10 @@ class LayerTree { uint32_t scene_version_; std::unique_ptr root_layer_; - base::TimeDelta construction_time_; + ftl::TimeDelta construction_time_; uint32_t rasterizer_tracing_threshold_; - DISALLOW_COPY_AND_ASSIGN(LayerTree); + FTL_DISALLOW_COPY_AND_ASSIGN(LayerTree); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/opacity_layer.cc b/engine/src/flutter/flow/layers/opacity_layer.cc index f9223b7d9e5..6fc68f493ef 100644 --- a/engine/src/flutter/flow/layers/opacity_layer.cc +++ b/engine/src/flutter/flow/layers/opacity_layer.cc @@ -6,11 +6,9 @@ namespace flow { -OpacityLayer::OpacityLayer() { -} +OpacityLayer::OpacityLayer() {} -OpacityLayer::~OpacityLayer() { -} +OpacityLayer::~OpacityLayer() {} void OpacityLayer::Paint(PaintContext& context) { TRACE_EVENT0("flutter", "OpacityLayer::Paint"); diff --git a/engine/src/flutter/flow/layers/opacity_layer.h b/engine/src/flutter/flow/layers/opacity_layer.h index 70a846081fe..17a3edf03af 100644 --- a/engine/src/flutter/flow/layers/opacity_layer.h +++ b/engine/src/flutter/flow/layers/opacity_layer.h @@ -22,7 +22,7 @@ class OpacityLayer : public ContainerLayer { private: int alpha_; - DISALLOW_COPY_AND_ASSIGN(OpacityLayer); + FTL_DISALLOW_COPY_AND_ASSIGN(OpacityLayer); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/performance_overlay_layer.cc b/engine/src/flutter/flow/layers/performance_overlay_layer.cc index d056ffa6455..77e676876dc 100644 --- a/engine/src/flutter/flow/layers/performance_overlay_layer.cc +++ b/engine/src/flutter/flow/layers/performance_overlay_layer.cc @@ -31,8 +31,8 @@ void VisualizeStopWatch(SkCanvas& canvas, bool show_graph, bool show_labels, const std::string& label_prefix) { - const int label_x = 8; // distance from x - const int label_y = -10; // distance from y+height + const int label_x = 8; // distance from x + const int label_y = -10; // distance from y+height if (show_graph) { SkRect visualization_rect = SkRect::MakeXYWH(x, y, width, height); @@ -40,10 +40,10 @@ void VisualizeStopWatch(SkCanvas& canvas, } if (show_labels) { - double ms_per_frame = stopwatch.MaxDelta().InMillisecondsF(); + double ms_per_frame = stopwatch.MaxDelta().ToMillisecondsF(); double fps; if (ms_per_frame < kOneFrameMS) { - fps = 1e3 / kOneFrameMS; + fps = 1e3 / kOneFrameMS; } else { fps = 1e3 / ms_per_frame; } @@ -51,8 +51,8 @@ void VisualizeStopWatch(SkCanvas& canvas, std::stringstream stream; stream.setf(std::ios::fixed | std::ios::showpoint); stream << std::setprecision(1); - stream << label_prefix << " " << fps << " fps " - << ms_per_frame << "ms/frame"; + stream << label_prefix << " " << fps << " fps " << ms_per_frame + << "ms/frame"; DrawStatisticsText(canvas, stream.str(), x + label_x, y + height + label_y); } } @@ -60,9 +60,7 @@ void VisualizeStopWatch(SkCanvas& canvas, } // namespace PerformanceOverlayLayer::PerformanceOverlayLayer(uint64_t options) - : options_(options) { -} - + : options_(options) {} void PerformanceOverlayLayer::Paint(PaintContext& context) { if (!options_) @@ -75,17 +73,13 @@ void PerformanceOverlayLayer::Paint(PaintContext& context) { SkScalar height = paint_bounds().height() / 2; SkAutoCanvasRestore save(&context.canvas, true); - VisualizeStopWatch(context.canvas, context.frame_time, - x, y, width, height, + VisualizeStopWatch(context.canvas, context.frame_time, x, y, width, height, options_ & kVisualizeRasterizerStatistics, - options_ & kDisplayRasterizerStatistics, - "Rasterizer"); + options_ & kDisplayRasterizerStatistics, "Rasterizer"); - VisualizeStopWatch(context.canvas, context.engine_time, - x, y + height, width, height, - options_ & kVisualizeEngineStatistics, - options_ & kDisplayEngineStatistics, - "Engine"); + VisualizeStopWatch(context.canvas, context.engine_time, x, y + height, width, + height, options_ & kVisualizeEngineStatistics, + options_ & kDisplayEngineStatistics, "Engine"); } } // namespace flow diff --git a/engine/src/flutter/flow/layers/performance_overlay_layer.h b/engine/src/flutter/flow/layers/performance_overlay_layer.h index ac5d6735adb..51ec8eb9566 100644 --- a/engine/src/flutter/flow/layers/performance_overlay_layer.h +++ b/engine/src/flutter/flow/layers/performance_overlay_layer.h @@ -5,8 +5,8 @@ #ifndef FLOW_LAYERS_PERFORMANCE_OVERLAY_LAYER_H_ #define FLOW_LAYERS_PERFORMANCE_OVERLAY_LAYER_H_ -#include "base/macros.h" #include "flow/layers/layer.h" +#include "lib/ftl/macros.h" namespace flow { @@ -24,7 +24,7 @@ class PerformanceOverlayLayer : public Layer { private: int options_; - DISALLOW_COPY_AND_ASSIGN(PerformanceOverlayLayer); + FTL_DISALLOW_COPY_AND_ASSIGN(PerformanceOverlayLayer); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/picture_layer.cc b/engine/src/flutter/flow/layers/picture_layer.cc index f4d1088cf28..11b2f3eb565 100644 --- a/engine/src/flutter/flow/layers/picture_layer.cc +++ b/engine/src/flutter/flow/layers/picture_layer.cc @@ -4,9 +4,9 @@ #include "flow/layers/picture_layer.h" -#include "base/logging.h" #include "flow/checkerboard.h" #include "flow/raster_cache.h" +#include "lib/ftl/logging.h" namespace flow { @@ -25,7 +25,7 @@ void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { } void PictureLayer::Paint(PaintContext& context) { - DCHECK(picture_); + FTL_DCHECK(picture_); if (image_) { TRACE_EVENT1("flutter", "PictureLayer::Paint", "image", "prerolled"); diff --git a/engine/src/flutter/flow/layers/picture_layer.h b/engine/src/flutter/flow/layers/picture_layer.h index a499a1c23dd..4cd07967c3d 100644 --- a/engine/src/flutter/flow/layers/picture_layer.h +++ b/engine/src/flutter/flow/layers/picture_layer.h @@ -34,7 +34,7 @@ class PictureLayer : public Layer { // If we rasterized the picture separately, image_ holds the pixels. sk_sp image_; - DISALLOW_COPY_AND_ASSIGN(PictureLayer); + FTL_DISALLOW_COPY_AND_ASSIGN(PictureLayer); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/shader_mask_layer.cc b/engine/src/flutter/flow/layers/shader_mask_layer.cc index 36eaf7c05ac..5d57f616bc9 100644 --- a/engine/src/flutter/flow/layers/shader_mask_layer.cc +++ b/engine/src/flutter/flow/layers/shader_mask_layer.cc @@ -6,11 +6,9 @@ namespace flow { -ShaderMaskLayer::ShaderMaskLayer() { -} +ShaderMaskLayer::ShaderMaskLayer() {} -ShaderMaskLayer::~ShaderMaskLayer() { -} +ShaderMaskLayer::~ShaderMaskLayer() {} void ShaderMaskLayer::Paint(PaintContext& context) { TRACE_EVENT0("flutter", "ShaderMaskLayer::Paint"); diff --git a/engine/src/flutter/flow/layers/shader_mask_layer.h b/engine/src/flutter/flow/layers/shader_mask_layer.h index 52d395bc3df..31a34b823b7 100644 --- a/engine/src/flutter/flow/layers/shader_mask_layer.h +++ b/engine/src/flutter/flow/layers/shader_mask_layer.h @@ -18,9 +18,7 @@ class ShaderMaskLayer : public ContainerLayer { void set_shader(sk_sp shader) { shader_ = shader; } - void set_mask_rect(const SkRect& mask_rect) { - mask_rect_ = mask_rect; - } + void set_mask_rect(const SkRect& mask_rect) { mask_rect_ = mask_rect; } void set_transfer_mode(SkXfermode::Mode transfer_mode) { transfer_mode_ = transfer_mode; @@ -34,7 +32,7 @@ class ShaderMaskLayer : public ContainerLayer { SkRect mask_rect_; SkXfermode::Mode transfer_mode_; - DISALLOW_COPY_AND_ASSIGN(ShaderMaskLayer); + FTL_DISALLOW_COPY_AND_ASSIGN(ShaderMaskLayer); }; } // namespace flow diff --git a/engine/src/flutter/flow/layers/transform_layer.cc b/engine/src/flutter/flow/layers/transform_layer.cc index 3ef37b5e1c8..1b913c099d9 100644 --- a/engine/src/flutter/flow/layers/transform_layer.cc +++ b/engine/src/flutter/flow/layers/transform_layer.cc @@ -6,11 +6,9 @@ namespace flow { -TransformLayer::TransformLayer() { -} +TransformLayer::TransformLayer() {} -TransformLayer::~TransformLayer() { -} +TransformLayer::~TransformLayer() {} void TransformLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkMatrix childMatrix; diff --git a/engine/src/flutter/flow/layers/transform_layer.h b/engine/src/flutter/flow/layers/transform_layer.h index c90da82309b..9239a7cdc39 100644 --- a/engine/src/flutter/flow/layers/transform_layer.h +++ b/engine/src/flutter/flow/layers/transform_layer.h @@ -22,7 +22,7 @@ class TransformLayer : public ContainerLayer { private: SkMatrix transform_; - DISALLOW_COPY_AND_ASSIGN(TransformLayer); + FTL_DISALLOW_COPY_AND_ASSIGN(TransformLayer); }; } // namespace flow diff --git a/engine/src/flutter/flow/open_gl.h b/engine/src/flutter/flow/open_gl.h index 88b6c146fb4..13bcb0606f5 100644 --- a/engine/src/flutter/flow/open_gl.h +++ b/engine/src/flutter/flow/open_gl.h @@ -5,7 +5,7 @@ #ifndef FLOW_OPEN_GL_H_ #define FLOW_OPEN_GL_H_ -#include "build/build_config.h" +#include "lib/ftl/build_config.h" #if OS_IOS diff --git a/engine/src/flutter/flow/raster_cache.cc b/engine/src/flutter/flow/raster_cache.cc index d1f9293bf7f..76484330d3b 100644 --- a/engine/src/flutter/flow/raster_cache.cc +++ b/engine/src/flutter/flow/raster_cache.cc @@ -4,8 +4,8 @@ #include "flow/raster_cache.h" -#include "base/logging.h" #include "base/trace_event/trace_event.h" +#include "lib/ftl/logging.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkPicture.h" diff --git a/engine/src/flutter/flow/raster_cache.h b/engine/src/flutter/flow/raster_cache.h index bcf9908a1a7..f1263ebd412 100644 --- a/engine/src/flutter/flow/raster_cache.h +++ b/engine/src/flutter/flow/raster_cache.h @@ -8,11 +8,11 @@ #include #include -#include "base/macros.h" -#include "skia/ext/refptr.h" -#include "third_party/skia/include/core/SkSize.h" -#include "third_party/skia/include/core/SkImage.h" #include "flow/instrumentation.h" +#include "lib/ftl/macros.h" +#include "skia/ext/refptr.h" +#include "third_party/skia/include/core/SkImage.h" +#include "third_party/skia/include/core/SkSize.h" namespace flow { @@ -44,7 +44,7 @@ class RasterCache { using Cache = std::unordered_map; Cache cache_; - DISALLOW_COPY_AND_ASSIGN(RasterCache); + FTL_DISALLOW_COPY_AND_ASSIGN(RasterCache); }; } // namespace flow diff --git a/engine/src/flutter/flow/texture_image.h b/engine/src/flutter/flow/texture_image.h index 732371c7124..92a9031ec73 100644 --- a/engine/src/flutter/flow/texture_image.h +++ b/engine/src/flutter/flow/texture_image.h @@ -5,7 +5,6 @@ #ifndef FLOW_TEXTURE_IMAGE_H_ #define FLOW_TEXTURE_IMAGE_H_ -#include "base/macros.h" #include "third_party/skia/include/core/SkImage.h" namespace flow {