diff --git a/flow/compositor_context.cc b/flow/compositor_context.cc index 01e23e057196c..ddf9f1c698893 100644 --- a/flow/compositor_context.cc +++ b/flow/compositor_context.cc @@ -9,10 +9,8 @@ namespace flutter { -CompositorContext::CompositorContext(Delegate& delegate) - : delegate_(delegate), - raster_time_(delegate.GetFrameBudget()), - ui_time_(delegate.GetFrameBudget()) {} +CompositorContext::CompositorContext(fml::Milliseconds frame_budget) + : raster_time_(frame_budget), ui_time_(frame_budget) {} CompositorContext::~CompositorContext() = default; @@ -25,11 +23,8 @@ void CompositorContext::BeginFrame(ScopedFrame& frame, } void CompositorContext::EndFrame(ScopedFrame& frame, - bool enable_instrumentation, - size_t freed_hint) { - freed_hint += raster_cache_.SweepAfterFrame(); - delegate_.OnCompositorEndFrame(freed_hint); - + bool enable_instrumentation) { + raster_cache_.SweepAfterFrame(); if (enable_instrumentation) { raster_time_.Stop(); } @@ -69,7 +64,7 @@ CompositorContext::ScopedFrame::ScopedFrame( } CompositorContext::ScopedFrame::~ScopedFrame() { - context_.EndFrame(*this, instrumentation_enabled_, uncached_external_size_); + context_.EndFrame(*this, instrumentation_enabled_); } RasterStatus CompositorContext::ScopedFrame::Raster( diff --git a/flow/compositor_context.h b/flow/compositor_context.h index b17dc907420da..47992abda6028 100644 --- a/flow/compositor_context.h +++ b/flow/compositor_context.h @@ -37,18 +37,6 @@ enum class RasterStatus { class CompositorContext { public: - class Delegate { - public: - /// Called at the end of a frame with approximately how many bytes mightbe - /// freed if a GC ran now. - /// - /// This method is called from the raster task runner. - virtual void OnCompositorEndFrame(size_t freed_hint) = 0; - - /// Time limit for a smooth frame. See `Engine::GetDisplayRefreshRate`. - virtual fml::Milliseconds GetFrameBudget() = 0; - }; - class ScopedFrame { public: ScopedFrame(CompositorContext& context, @@ -79,8 +67,6 @@ class CompositorContext { virtual RasterStatus Raster(LayerTree& layer_tree, bool ignore_raster_cache); - void add_external_size(size_t size) { uncached_external_size_ += size; } - private: CompositorContext& context_; GrDirectContext* gr_context_; @@ -90,12 +76,11 @@ class CompositorContext { const bool instrumentation_enabled_; const bool surface_supports_readback_; fml::RefPtr raster_thread_merger_; - size_t uncached_external_size_ = 0; FML_DISALLOW_COPY_AND_ASSIGN(ScopedFrame); }; - explicit CompositorContext(Delegate& delegate); + CompositorContext(fml::Milliseconds frame_budget = fml::kDefaultFrameBudget); virtual ~CompositorContext(); @@ -123,7 +108,6 @@ class CompositorContext { Stopwatch& ui_time() { return ui_time_; } private: - Delegate& delegate_; RasterCache raster_cache_; TextureRegistry texture_registry_; Counter frame_count_; @@ -132,9 +116,7 @@ class CompositorContext { void BeginFrame(ScopedFrame& frame, bool enable_instrumentation); - void EndFrame(ScopedFrame& frame, - bool enable_instrumentation, - size_t freed_hint); + void EndFrame(ScopedFrame& frame, bool enable_instrumentation); FML_DISALLOW_COPY_AND_ASSIGN(CompositorContext); }; diff --git a/flow/layers/layer.cc b/flow/layers/layer.cc index 490f123ec5f6f..a242f977cde29 100644 --- a/flow/layers/layer.cc +++ b/flow/layers/layer.cc @@ -9,11 +9,10 @@ namespace flutter { -Layer::Layer(size_t external_size) +Layer::Layer() : paint_bounds_(SkRect::MakeEmpty()), unique_id_(NextUniqueID()), - needs_system_composite_(false), - external_size_(external_size) {} + needs_system_composite_(false) {} Layer::~Layer() = default; diff --git a/flow/layers/layer.h b/flow/layers/layer.h index 5e75b3937ca18..f9732760a7770 100644 --- a/flow/layers/layer.h +++ b/flow/layers/layer.h @@ -67,14 +67,13 @@ struct PrerollContext { // Informs whether a layer needs to be system composited. bool child_scene_layer_exists_below = false; #endif - size_t uncached_external_size = 0; }; // Represents a single composited layer. Created on the UI thread but then // subquently used on the Rasterizer thread. class Layer { public: - Layer(size_t external_size = 0); + Layer(); virtual ~Layer(); virtual void Preroll(PrerollContext* context, const SkMatrix& matrix); @@ -179,8 +178,6 @@ class Layer { uint64_t unique_id() const { return unique_id_; } - size_t external_size() const { return external_size_; } - protected: #if defined(LEGACY_FUCHSIA_EMBEDDER) bool child_layer_exists_below_ = false; @@ -190,7 +187,6 @@ class Layer { SkRect paint_bounds_; uint64_t unique_id_; bool needs_system_composite_; - size_t external_size_ = 0; static uint64_t NextUniqueID(); diff --git a/flow/layers/layer_tree.cc b/flow/layers/layer_tree.cc index 160c8c50e1024..e0ac5157fc746 100644 --- a/flow/layers/layer_tree.cc +++ b/flow/layers/layer_tree.cc @@ -58,7 +58,6 @@ bool LayerTree::Preroll(CompositorContext::ScopedFrame& frame, device_pixel_ratio_}; root_layer_->Preroll(&context, frame.root_surface_transformation()); - frame.add_external_size(context.uncached_external_size); return context.surface_needs_readback; } diff --git a/flow/layers/layer_tree_unittests.cc b/flow/layers/layer_tree_unittests.cc index 99231f8254edd..7045497692afe 100644 --- a/flow/layers/layer_tree_unittests.cc +++ b/flow/layers/layer_tree_unittests.cc @@ -15,11 +15,11 @@ namespace flutter { namespace testing { -class LayerTreeTest : public CanvasTest, public CompositorContext::Delegate { +class LayerTreeTest : public CanvasTest { public: LayerTreeTest() : layer_tree_(SkISize::Make(64, 64), 1.0f), - compositor_context_(*this), + compositor_context_(fml::kDefaultFrameBudget), root_transform_(SkMatrix::Translate(1.0f, 1.0f)), scoped_frame_(compositor_context_.AcquireFrame(nullptr, &mock_canvas(), @@ -33,24 +33,11 @@ class LayerTreeTest : public CanvasTest, public CompositorContext::Delegate { CompositorContext::ScopedFrame& frame() { return *scoped_frame_.get(); } const SkMatrix& root_transform() { return root_transform_; } - // |CompositorContext::Delegate| - void OnCompositorEndFrame(size_t freed_hint) override { - last_freed_hint_ = freed_hint; - } - - // |CompositorContext::Delegate| - fml::Milliseconds GetFrameBudget() override { - return fml::kDefaultFrameBudget; - } - - size_t last_freed_hint() { return last_freed_hint_; } - private: LayerTree layer_tree_; CompositorContext compositor_context_; SkMatrix root_transform_; std::unique_ptr scoped_frame_; - size_t last_freed_hint_ = 0; }; TEST_F(LayerTreeTest, PaintingEmptyLayerDies) { diff --git a/flow/layers/picture_layer.cc b/flow/layers/picture_layer.cc index 067a59d782398..d5d6a34b573e8 100644 --- a/flow/layers/picture_layer.cc +++ b/flow/layers/picture_layer.cc @@ -11,10 +11,8 @@ namespace flutter { PictureLayer::PictureLayer(const SkPoint& offset, SkiaGPUObject picture, bool is_complex, - bool will_change, - size_t external_size) - : Layer(external_size), - offset_(offset), + bool will_change) + : offset_(offset), picture_(std::move(picture)), is_complex_(is_complex), will_change_(will_change) {} @@ -28,7 +26,6 @@ void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { SkPicture* sk_picture = picture(); - bool cached = false; if (auto* cache = context->raster_cache) { TRACE_EVENT0("flutter", "PictureLayer::RasterCache (Preroll)"); @@ -37,13 +34,8 @@ void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { #ifndef SUPPORT_FRACTIONAL_TRANSLATION ctm = RasterCache::GetIntegralTransCTM(ctm); #endif - cached = cache->Prepare(context->gr_context, sk_picture, ctm, - context->dst_color_space, is_complex_, will_change_, - external_size()); - } - - if (!cached) { - context->uncached_external_size += external_size(); + cache->Prepare(context->gr_context, sk_picture, ctm, + context->dst_color_space, is_complex_, will_change_); } SkRect bounds = sk_picture->cullRect().makeOffset(offset_.x(), offset_.y()); diff --git a/flow/layers/picture_layer.h b/flow/layers/picture_layer.h index c86361a9aaaae..e733e7455ca6c 100644 --- a/flow/layers/picture_layer.h +++ b/flow/layers/picture_layer.h @@ -18,8 +18,7 @@ class PictureLayer : public Layer { PictureLayer(const SkPoint& offset, SkiaGPUObject picture, bool is_complex, - bool will_change, - size_t external_size); + bool will_change); SkPicture* picture() const { return picture_.get().get(); } diff --git a/flow/layers/picture_layer_unittests.cc b/flow/layers/picture_layer_unittests.cc index b7bfce854ed82..dc9e6080c1508 100644 --- a/flow/layers/picture_layer_unittests.cc +++ b/flow/layers/picture_layer_unittests.cc @@ -24,7 +24,7 @@ using PictureLayerTest = SkiaGPUObjectLayerTest; TEST_F(PictureLayerTest, PaintBeforePrerollInvalidPictureDies) { const SkPoint layer_offset = SkPoint::Make(0.0f, 0.0f); auto layer = std::make_shared( - layer_offset, SkiaGPUObject(), false, false, 0); + layer_offset, SkiaGPUObject(), false, false); EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()), "picture_\\.get\\(\\)"); @@ -35,8 +35,7 @@ TEST_F(PictureLayerTest, PaintBeforePreollDies) { const SkRect picture_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f); auto mock_picture = SkPicture::MakePlaceholder(picture_bounds); auto layer = std::make_shared( - layer_offset, SkiaGPUObject(mock_picture, unref_queue()), false, false, - 0); + layer_offset, SkiaGPUObject(mock_picture, unref_queue()), false, false); EXPECT_EQ(layer->paint_bounds(), SkRect::MakeEmpty()); EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()), @@ -48,8 +47,7 @@ TEST_F(PictureLayerTest, PaintingEmptyLayerDies) { const SkRect picture_bounds = SkRect::MakeEmpty(); auto mock_picture = SkPicture::MakePlaceholder(picture_bounds); auto layer = std::make_shared( - layer_offset, SkiaGPUObject(mock_picture, unref_queue()), false, false, - 0); + layer_offset, SkiaGPUObject(mock_picture, unref_queue()), false, false); layer->Preroll(preroll_context(), SkMatrix()); EXPECT_EQ(layer->paint_bounds(), SkRect::MakeEmpty()); @@ -64,7 +62,7 @@ TEST_F(PictureLayerTest, PaintingEmptyLayerDies) { TEST_F(PictureLayerTest, InvalidPictureDies) { const SkPoint layer_offset = SkPoint::Make(0.0f, 0.0f); auto layer = std::make_shared( - layer_offset, SkiaGPUObject(), false, false, 0); + layer_offset, SkiaGPUObject(), false, false); // Crashes reading a nullptr. EXPECT_DEATH_IF_SUPPORTED(layer->Preroll(preroll_context(), SkMatrix()), ""); @@ -77,10 +75,7 @@ TEST_F(PictureLayerTest, SimplePicture) { const SkRect picture_bounds = SkRect::MakeLTRB(5.0f, 6.0f, 20.5f, 21.5f); auto mock_picture = SkPicture::MakePlaceholder(picture_bounds); auto layer = std::make_shared( - layer_offset, SkiaGPUObject(mock_picture, unref_queue()), false, false, - 1000); - - EXPECT_EQ(layer->external_size(), 1000ul); + layer_offset, SkiaGPUObject(mock_picture, unref_queue()), false, false); layer->Preroll(preroll_context(), SkMatrix()); EXPECT_EQ(layer->paint_bounds(), diff --git a/flow/raster_cache.cc b/flow/raster_cache.cc index f077d215a28d4..72f55bc7e3bef 100644 --- a/flow/raster_cache.cc +++ b/flow/raster_cache.cc @@ -141,7 +141,6 @@ void RasterCache::Prepare(PrerollContext* context, Entry& entry = layer_cache_[cache_key]; entry.access_count++; entry.used_this_frame = true; - entry.external_size = layer->external_size(); if (!entry.image) { entry.image = RasterizeLayer(context, layer, ctm, checkerboard_images_); } @@ -182,8 +181,7 @@ bool RasterCache::Prepare(GrDirectContext* context, const SkMatrix& transformation_matrix, SkColorSpace* dst_color_space, bool is_complex, - bool will_change, - size_t external_size) { + bool will_change) { // Disabling caching when access_threshold is zero is historic behavior. if (access_threshold_ == 0) { return false; @@ -209,7 +207,6 @@ bool RasterCache::Prepare(GrDirectContext* context, // Creates an entry, if not present prior. Entry& entry = picture_cache_[cache_key]; - entry.external_size = external_size; if (entry.access_count < access_threshold_) { // Frame threshold has not yet been reached. return false; @@ -263,12 +260,11 @@ bool RasterCache::Draw(const Layer* layer, return false; } -size_t RasterCache::SweepAfterFrame() { - size_t removed_size = SweepOneCacheAfterFrame(picture_cache_); - removed_size += SweepOneCacheAfterFrame(layer_cache_); +void RasterCache::SweepAfterFrame() { + SweepOneCacheAfterFrame(picture_cache_); + SweepOneCacheAfterFrame(layer_cache_); picture_cached_this_frame_ = 0; TraceStatsToTimeline(); - return removed_size; } void RasterCache::Clear() { diff --git a/flow/raster_cache.h b/flow/raster_cache.h index 901757974abc1..297a58482f056 100644 --- a/flow/raster_cache.h +++ b/flow/raster_cache.h @@ -137,8 +137,7 @@ class RasterCache { const SkMatrix& transformation_matrix, SkColorSpace* dst_color_space, bool is_complex, - bool will_change, - size_t external_size = 0); + bool will_change); void Prepare(PrerollContext* context, Layer* layer, const SkMatrix& ctm); @@ -157,8 +156,7 @@ class RasterCache { SkCanvas& canvas, SkPaint* paint = nullptr) const; - /// Returns the amount of external bytes freed by the sweep. - size_t SweepAfterFrame(); + void SweepAfterFrame(); void Clear(); @@ -194,20 +192,17 @@ class RasterCache { struct Entry { bool used_this_frame = false; size_t access_count = 0; - size_t external_size = 0; std::unique_ptr image; }; template - static size_t SweepOneCacheAfterFrame(Cache& cache) { + static void SweepOneCacheAfterFrame(Cache& cache) { std::vector dead; - size_t removed_size = 0; for (auto it = cache.begin(); it != cache.end(); ++it) { Entry& entry = it->second; if (!entry.used_this_frame) { dead.push_back(it); - removed_size += entry.external_size; } entry.used_this_frame = false; } @@ -215,7 +210,6 @@ class RasterCache { for (auto it : dead) { cache.erase(it); } - return removed_size; } const size_t access_threshold_; diff --git a/lib/ui/compositing/scene_builder.cc b/lib/ui/compositing/scene_builder.cc index b60a5f1c67caa..1c0fa9bd5597f 100644 --- a/lib/ui/compositing/scene_builder.cc +++ b/lib/ui/compositing/scene_builder.cc @@ -220,7 +220,7 @@ void SceneBuilder::addPicture(double dx, pictureRect.offset(offset.x(), offset.y()); auto layer = std::make_unique( offset, UIDartState::CreateGPUObject(picture->picture()), !!(hints & 1), - !!(hints & 2), picture->GetAllocationSize()); + !!(hints & 2)); AddLayer(std::move(layer)); } diff --git a/lib/ui/fixtures/ui_test.dart b/lib/ui/fixtures/ui_test.dart index 478c919066562..e2fcdaa7c3e8b 100644 --- a/lib/ui/fixtures/ui_test.dart +++ b/lib/ui/fixtures/ui_test.dart @@ -3,7 +3,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:async'; import 'dart:typed_data'; import 'dart:ui'; @@ -74,59 +73,3 @@ Future encodeImageProducesExternalUint8List() async { void _encodeImage(Image i, int format, void Function(Uint8List result)) native 'EncodeImage'; void _validateExternal(Uint8List result) native 'ValidateExternal'; - -@pragma('vm:entry-point') -Future pumpImage() async { - final FrameCallback renderBlank = (Duration duration) { - final PictureRecorder recorder = PictureRecorder(); - final Canvas canvas = Canvas(recorder); - canvas.drawRect(Rect.largest, Paint()); - final Picture picture = recorder.endRecording(); - - final SceneBuilder builder = SceneBuilder(); - builder.addPicture(Offset.zero, picture); - - final Scene scene = builder.build(); - window.render(scene); - scene.dispose(); - window.onBeginFrame = (Duration duration) { - window.onDrawFrame = _onBeginFrameDone; - }; - window.scheduleFrame(); - }; - - final FrameCallback renderImage = (Duration duration) { - const int width = 8000; - const int height = 8000; - final Completer completer = Completer(); - decodeImageFromPixels( - Uint8List.fromList(List.filled(width * height * 4, 0xFF)), - width, - height, - PixelFormat.rgba8888, - (Image image) => completer.complete(image), - ); - completer.future.then((Image image) { - final PictureRecorder recorder = PictureRecorder(); - final Canvas canvas = Canvas(recorder); - canvas.drawImage(image, Offset.zero, Paint()); - final Picture picture = recorder.endRecording(); - - final SceneBuilder builder = SceneBuilder(); - builder.addPicture(Offset.zero, picture); - - _captureImageAndPicture(image, picture); - - final Scene scene = builder.build(); - window.render(scene); - scene.dispose(); - window.onBeginFrame = renderBlank; - window.scheduleFrame(); - }); - }; - - window.onBeginFrame = renderImage; - window.scheduleFrame(); -} -void _captureImageAndPicture(Image image, Picture picture) native 'CaptureImageAndPicture'; -Future _onBeginFrameDone() native 'OnBeginFrameDone'; diff --git a/runtime/runtime_controller.cc b/runtime/runtime_controller.cc index 9c81d6a759cdb..f66cfed778660 100644 --- a/runtime/runtime_controller.cc +++ b/runtime/runtime_controller.cc @@ -233,7 +233,7 @@ bool RuntimeController::ReportTimings(std::vector timings) { return false; } -bool RuntimeController::NotifyIdle(int64_t deadline, size_t freed_hint) { +bool RuntimeController::NotifyIdle(int64_t deadline) { std::shared_ptr root_isolate = root_isolate_.lock(); if (!root_isolate) { return false; @@ -241,9 +241,6 @@ bool RuntimeController::NotifyIdle(int64_t deadline, size_t freed_hint) { tonic::DartState::Scope scope(root_isolate); - // Dart will use the freed hint at the next idle notification. Make sure to - // Update it with our latest value before calling NotifyIdle. - Dart_HintFreed(freed_hint); Dart_NotifyIdle(deadline); // Idle notifications being in isolate scope are part of the contract. diff --git a/runtime/runtime_controller.h b/runtime/runtime_controller.h index e1b29f127a79f..18adbc2c1d720 100644 --- a/runtime/runtime_controller.h +++ b/runtime/runtime_controller.h @@ -329,12 +329,9 @@ class RuntimeController : public PlatformConfigurationClient { /// system's monotonic time. The clock can be accessed via /// `Dart_TimelineGetMicros`. /// - /// @param[in] freed_hint A hint of the number of bytes potentially freed - /// since the last call to NotifyIdle if a GC were run. - /// /// @return If the idle notification was forwarded to the running isolate. /// - bool NotifyIdle(int64_t deadline, size_t freed_hint); + bool NotifyIdle(int64_t deadline); //---------------------------------------------------------------------------- /// @brief Returns if the root isolate is running. The isolate must be diff --git a/shell/common/engine.cc b/shell/common/engine.cc index dbbac6e583b15..315780f23346b 100644 --- a/shell/common/engine.cc +++ b/shell/common/engine.cc @@ -248,16 +248,11 @@ void Engine::ReportTimings(std::vector timings) { runtime_controller_->ReportTimings(std::move(timings)); } -void Engine::HintFreed(size_t size) { - hint_freed_bytes_since_last_idle_ += size; -} - void Engine::NotifyIdle(int64_t deadline) { auto trace_event = std::to_string(deadline - Dart_TimelineGetMicros()); TRACE_EVENT1("flutter", "Engine::NotifyIdle", "deadline_now_delta", trace_event.c_str()); - runtime_controller_->NotifyIdle(deadline, hint_freed_bytes_since_last_idle_); - hint_freed_bytes_since_last_idle_ = 0; + runtime_controller_->NotifyIdle(deadline); } std::pair Engine::GetUIIsolateReturnCode() { diff --git a/shell/common/engine.h b/shell/common/engine.h index 97165f42a69fa..d16ae0ffed2c7 100644 --- a/shell/common/engine.h +++ b/shell/common/engine.h @@ -465,14 +465,6 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate { /// void BeginFrame(fml::TimePoint frame_time); - //---------------------------------------------------------------------------- - /// @brief Notifies the engine that native bytes might be freed if a - /// garbage collection ran now. - /// - /// @param[in] size The number of bytes freed. - /// - void HintFreed(size_t size); - //---------------------------------------------------------------------------- /// @brief Notifies the engine that the UI task runner is not expected to /// undertake a new frame workload till a specified timepoint. The @@ -805,7 +797,6 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate { FontCollection font_collection_; ImageDecoder image_decoder_; TaskRunners task_runners_; - size_t hint_freed_bytes_since_last_idle_ = 0; fml::WeakPtrFactory weak_factory_; // |RuntimeDelegate| diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index e6abdbd155a22..f043eb8a8d1c2 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -27,7 +27,8 @@ static constexpr std::chrono::milliseconds kSkiaCleanupExpiration(15000); Rasterizer::Rasterizer(Delegate& delegate) : Rasterizer(delegate, - std::make_unique(delegate)) {} + std::make_unique( + delegate.GetFrameBudget())) {} Rasterizer::Rasterizer( Delegate& delegate, diff --git a/shell/common/rasterizer.h b/shell/common/rasterizer.h index 963a0998db465..8fbfd973150ea 100644 --- a/shell/common/rasterizer.h +++ b/shell/common/rasterizer.h @@ -50,7 +50,7 @@ class Rasterizer final : public SnapshotDelegate { /// are made on the GPU task runner. Any delegate must ensure that /// they can handle the threading implications. /// - class Delegate : public CompositorContext::Delegate { + class Delegate { public: //-------------------------------------------------------------------------- /// @brief Notifies the delegate that a frame has been rendered. The diff --git a/shell/common/shell.cc b/shell/common/shell.cc index f4651184c0e08..97c4cde047d27 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -1179,16 +1179,6 @@ void Shell::OnFrameRasterized(const FrameTiming& timing) { } } -void Shell::OnCompositorEndFrame(size_t freed_hint) { - FML_DCHECK(task_runners_.GetRasterTaskRunner()->RunsTasksOnCurrentThread()); - task_runners_.GetUITaskRunner()->PostTask( - [engine = weak_engine_, freed_hint = freed_hint]() { - if (engine) { - engine->HintFreed(freed_hint); - } - }); -} - fml::Milliseconds Shell::GetFrameBudget() { if (display_refresh_rate_ > 0) { return fml::RefreshRateToFrameBudget(display_refresh_rate_.load()); diff --git a/shell/common/shell.h b/shell/common/shell.h index aa9b64ae1ee32..dd09fad2ae7a6 100644 --- a/shell/common/shell.h +++ b/shell/common/shell.h @@ -12,7 +12,6 @@ #include "flutter/common/settings.h" #include "flutter/common/task_runners.h" -#include "flutter/flow/compositor_context.h" #include "flutter/flow/surface.h" #include "flutter/flow/texture.h" #include "flutter/fml/closure.h" @@ -529,14 +528,10 @@ class Shell final : public PlatformView::Delegate, void OnFrameRasterized(const FrameTiming&) override; // |Rasterizer::Delegate| - fml::TimePoint GetLatestFrameTargetTime() const override; - - // |Rasterizer::Delegate| - // |CompositorContext::Delegate| fml::Milliseconds GetFrameBudget() override; - // |CompositorContext::Delegate| - void OnCompositorEndFrame(size_t freed_hint) override; + // |Rasterizer::Delegate| + fml::TimePoint GetLatestFrameTargetTime() const override; // |ServiceProtocol::Handler| fml::RefPtr GetServiceProtocolHandlerTaskRunner( diff --git a/shell/common/shell_test.cc b/shell/common/shell_test.cc index e80652e33c059..8144d3accaacd 100644 --- a/shell/common/shell_test.cc +++ b/shell/common/shell_test.cc @@ -106,40 +106,6 @@ void ShellTest::VSyncFlush(Shell* shell, bool& will_draw_new_frame) { latch.Wait(); } -void ShellTest::SetViewportMetrics(Shell* shell, double width, double height) { - flutter::ViewportMetrics viewport_metrics = { - 1, // device pixel ratio - width, // physical width - height, // physical height - 0, // padding top - 0, // padding right - 0, // padding bottom - 0, // padding left - 0, // view inset top - 0, // view inset right - 0, // view inset bottom - 0, // view inset left - 0, // gesture inset top - 0, // gesture inset right - 0, // gesture inset bottom - 0 // gesture inset left - }; - // Set viewport to nonempty, and call Animator::BeginFrame to make the layer - // tree pipeline nonempty. Without either of this, the layer tree below - // won't be rasterized. - fml::AutoResetWaitableEvent latch; - shell->GetTaskRunners().GetUITaskRunner()->PostTask( - [&latch, engine = shell->weak_engine_, viewport_metrics]() { - engine->SetViewportMetrics(std::move(viewport_metrics)); - const auto frame_begin_time = fml::TimePoint::Now(); - const auto frame_end_time = - frame_begin_time + fml::TimeDelta::FromSecondsF(1.0 / 60.0); - engine->animator_->BeginFrame(frame_begin_time, frame_end_time); - latch.Signal(); - }); - latch.Wait(); -} - void ShellTest::PumpOneFrame(Shell* shell, double width, double height, diff --git a/shell/common/shell_test.h b/shell/common/shell_test.h index 5b626289cd766..c61aba37c7647 100644 --- a/shell/common/shell_test.h +++ b/shell/common/shell_test.h @@ -59,7 +59,6 @@ class ShellTest : public FixtureTest { /// the `will_draw_new_frame` to true. static void VSyncFlush(Shell* shell, bool& will_draw_new_frame); - static void SetViewportMetrics(Shell* shell, double width, double height); /// Given the root layer, this callback builds the layer tree to be rasterized /// in PumpOneFrame. using LayerTreeBuilder = diff --git a/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index 750b03f7a1c91..f368475d7a1d3 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -536,8 +536,7 @@ TEST_F(ShellTest, ExternalEmbedderNoThreadMerger) { this->GetCurrentTaskRunner(), fml::TimeDelta::FromSeconds(0)); auto picture_layer = std::make_shared( SkPoint::Make(10, 10), - flutter::SkiaGPUObject({sk_picture, queue}), false, false, - 0); + flutter::SkiaGPUObject({sk_picture, queue}), false, false); root->Add(picture_layer); }; @@ -586,8 +585,7 @@ TEST_F(ShellTest, this->GetCurrentTaskRunner(), fml::TimeDelta::FromSeconds(0)); auto picture_layer = std::make_shared( SkPoint::Make(10, 10), - flutter::SkiaGPUObject({sk_picture, queue}), false, false, - 0); + flutter::SkiaGPUObject({sk_picture, queue}), false, false); root->Add(picture_layer); }; @@ -637,8 +635,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyAfterMergingThreads) { this->GetCurrentTaskRunner(), fml::TimeDelta::FromSeconds(0)); auto picture_layer = std::make_shared( SkPoint::Make(10, 10), - flutter::SkiaGPUObject({sk_picture, queue}), false, false, - 0); + flutter::SkiaGPUObject({sk_picture, queue}), false, false); root->Add(picture_layer); }; @@ -706,8 +703,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyWhenThreadsAreMerging) { this->GetCurrentTaskRunner(), fml::TimeDelta::FromSeconds(0)); auto picture_layer = std::make_shared( SkPoint::Make(10, 10), - flutter::SkiaGPUObject({sk_picture, queue}), false, false, - 0); + flutter::SkiaGPUObject({sk_picture, queue}), false, false); root->Add(picture_layer); }; @@ -773,8 +769,7 @@ TEST_F(ShellTest, this->GetCurrentTaskRunner(), fml::TimeDelta::FromSeconds(0)); auto picture_layer = std::make_shared( SkPoint::Make(10, 10), - flutter::SkiaGPUObject({sk_picture, queue}), false, false, - 0); + flutter::SkiaGPUObject({sk_picture, queue}), false, false); root->Add(picture_layer); }; PumpOneFrame(shell.get(), 100, 100, builder); @@ -822,8 +817,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyWithoutRasterThreadMerger) { this->GetCurrentTaskRunner(), fml::TimeDelta::FromSeconds(0)); auto picture_layer = std::make_shared( SkPoint::Make(10, 10), - flutter::SkiaGPUObject({sk_picture, queue}), false, false, - 0); + flutter::SkiaGPUObject({sk_picture, queue}), false, false); root->Add(picture_layer); }; PumpOneFrame(shell.get(), 100, 100, builder); @@ -888,8 +882,7 @@ TEST_F(ShellTest, OnPlatformViewDestroyWithStaticThreadMerging) { this->GetCurrentTaskRunner(), fml::TimeDelta::FromSeconds(0)); auto picture_layer = std::make_shared( SkPoint::Make(10, 10), - flutter::SkiaGPUObject({sk_picture, queue}), false, false, - 0); + flutter::SkiaGPUObject({sk_picture, queue}), false, false); root->Add(picture_layer); }; PumpOneFrame(shell.get(), 100, 100, builder); @@ -1460,8 +1453,7 @@ TEST_F(ShellTest, Screenshot) { this->GetCurrentTaskRunner(), fml::TimeDelta::FromSeconds(0)); auto picture_layer = std::make_shared( SkPoint::Make(10, 10), - flutter::SkiaGPUObject({sk_picture, queue}), false, false, - 0); + flutter::SkiaGPUObject({sk_picture, queue}), false, false); root->Add(picture_layer); }; @@ -1747,7 +1739,7 @@ TEST_F(ShellTest, OnServiceProtocolEstimateRasterCacheMemoryWorks) { auto picture_layer = std::make_shared( SkPoint::Make(0, 0), flutter::SkiaGPUObject({MakeSizedPicture(100, 100), queue}), - false, false, 0); + false, false); picture_layer->set_paint_bounds(SkRect::MakeWH(100, 100)); // 2. Rasterize the picture and the picture layer in the raster cache. diff --git a/shell/common/skp_shader_warmup_unittests.cc b/shell/common/skp_shader_warmup_unittests.cc index ec81003c8f04f..689f2d9322fcc 100644 --- a/shell/common/skp_shader_warmup_unittests.cc +++ b/shell/common/skp_shader_warmup_unittests.cc @@ -153,8 +153,7 @@ class SkpWarmupTest : public ShellTest { auto picture_layer = std::make_shared( SkPoint::Make(0, 0), SkiaGPUObject(picture, queue), /* is_complex */ false, - /* will_change */ false, - /* external_size */ 0); + /* will_change */ false); root->Add(picture_layer); }; PumpOneFrame(shell.get(), picture->cullRect().width(), @@ -236,8 +235,7 @@ TEST_F(SkpWarmupTest, Image) { auto picture_layer = std::make_shared( SkPoint::Make(0, 0), SkiaGPUObject(picture, queue), /* is_complex */ false, - /* will_change */ false, - /* external_size */ 0); + /* will_change */ false); root->Add(picture_layer); }; diff --git a/shell/platform/fuchsia/flutter/compositor_context.cc b/shell/platform/fuchsia/flutter/compositor_context.cc index 6911ed8ddc2d5..599ebf77b0dd2 100644 --- a/shell/platform/fuchsia/flutter/compositor_context.cc +++ b/shell/platform/fuchsia/flutter/compositor_context.cc @@ -140,12 +140,10 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame { }; CompositorContext::CompositorContext( - flutter::CompositorContext::Delegate& delegate, SessionConnection& session_connection, VulkanSurfaceProducer& surface_producer, flutter::SceneUpdateContext& scene_update_context) - : flutter::CompositorContext(delegate), - session_connection_(session_connection), + : session_connection_(session_connection), surface_producer_(surface_producer), scene_update_context_(scene_update_context) {} diff --git a/shell/platform/fuchsia/flutter/compositor_context.h b/shell/platform/fuchsia/flutter/compositor_context.h index eb57321c1215c..542e5d314fa71 100644 --- a/shell/platform/fuchsia/flutter/compositor_context.h +++ b/shell/platform/fuchsia/flutter/compositor_context.h @@ -21,8 +21,7 @@ namespace flutter_runner { // Fuchsia. class CompositorContext final : public flutter::CompositorContext { public: - CompositorContext(CompositorContext::Delegate& delegate, - SessionConnection& session_connection, + CompositorContext(SessionConnection& session_connection, VulkanSurfaceProducer& surface_producer, flutter::SceneUpdateContext& scene_update_context); diff --git a/shell/platform/fuchsia/flutter/engine.cc b/shell/platform/fuchsia/flutter/engine.cc index 9470f3aae8b38..fe4dff020a8c6 100644 --- a/shell/platform/fuchsia/flutter/engine.cc +++ b/shell/platform/fuchsia/flutter/engine.cc @@ -221,7 +221,7 @@ Engine::Engine(Delegate& delegate, std::unique_ptr compositor_context = std::make_unique( - shell, session_connection_.value(), surface_producer_.value(), + session_connection_.value(), surface_producer_.value(), scene_update_context_.value()); return std::make_unique(