mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This PR connects the view ID provided by the rasterizer to `EmbedderExternalViewEmbedder`'s presenting call (see `embedder_external_view_embedder.cc`). This PR also contains a refactor (which actually takes the majority of LOC) that moves the specification of view ID from `PrepareFlutterView` to `SubmitFlutterView`. The `flutter_view_id` parameter in `PrepareFlutterView` was added in https://github.com/flutter/engine/pull/46169. It turns out that we don't need the view ID throughout the preparation phase, so we can delay the specification to submission, which makes it feel cleaner. ### Tests Existing tests are changed to verify that `SubmitFlutterView` receive the correct view ID. The feature that `EmbedderExternalViewEmbedder` sends the view ID to the presenting API is not tested for now, because `EmbedderExternalViewEmbedder` is typically tested in `embedder_unittests`, but it requires the embedder API `AddView`. It will be tested in later changes to `EmbedderExternalViewEmbedder`. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
// Copyright 2013 The Flutter 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_FLOW_TESTING_MOCK_EMBEDDER_H_
|
|
#define FLUTTER_FLOW_TESTING_MOCK_EMBEDDER_H_
|
|
|
|
#include "flutter/flow/embedded_views.h"
|
|
|
|
namespace flutter {
|
|
namespace testing {
|
|
|
|
class MockViewEmbedder : public ExternalViewEmbedder {
|
|
public:
|
|
MockViewEmbedder();
|
|
|
|
~MockViewEmbedder();
|
|
|
|
void AddCanvas(DlCanvas* canvas);
|
|
|
|
// |ExternalViewEmbedder|
|
|
DlCanvas* GetRootCanvas() override;
|
|
|
|
// |ExternalViewEmbedder|
|
|
void CancelFrame() override;
|
|
|
|
// |ExternalViewEmbedder|
|
|
void BeginFrame(GrDirectContext* context,
|
|
const fml::RefPtr<fml::RasterThreadMerger>&
|
|
raster_thread_merger) override;
|
|
|
|
// |ExternalViewEmbedder|
|
|
void PrepareFlutterView(SkISize frame_size,
|
|
double device_pixel_ratio) override;
|
|
|
|
// |ExternalViewEmbedder|
|
|
void PrerollCompositeEmbeddedView(
|
|
int64_t view_id,
|
|
std::unique_ptr<EmbeddedViewParams> params) override;
|
|
|
|
// |ExternalViewEmbedder|
|
|
DlCanvas* CompositeEmbeddedView(int64_t view_id) override;
|
|
|
|
std::vector<int64_t> prerolled_views() const { return prerolled_views_; }
|
|
std::vector<int64_t> painted_views() const { return painted_views_; }
|
|
|
|
private:
|
|
std::deque<DlCanvas*> contexts_;
|
|
std::vector<int64_t> prerolled_views_;
|
|
std::vector<int64_t> painted_views_;
|
|
};
|
|
|
|
} // namespace testing
|
|
} // namespace flutter
|
|
|
|
#endif // FLUTTER_FLOW_TESTING_MOCK_EMBEDDER_H_
|