Skip to content

Commit

Permalink
Make flow/embedded_views.h compatible with .clang_tidy. (flutter#…
Browse files Browse the repository at this point in the history
…47994)

Work towards flutter/flutter#134969.

All changes were made automatically (i.e. with `--fix`).
  • Loading branch information
matanlurey authored Nov 16, 2023
1 parent dd53c6e commit ea42577
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 107 deletions.
19 changes: 10 additions & 9 deletions flow/embedded_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define FLUTTER_FLOW_EMBEDDED_VIEWS_H_

#include <memory>
#include <utility>
#include <vector>

#include "flutter/display_list/dl_builder.h"
Expand Down Expand Up @@ -51,7 +52,7 @@ class ImageFilterMutation {
public:
ImageFilterMutation(std::shared_ptr<const DlImageFilter> filter,
const SkRect& filter_rect)
: filter_(filter), filter_rect_(filter_rect) {}
: filter_(std::move(filter)), filter_rect_(filter_rect) {}

const DlImageFilter& GetFilter() const { return *filter_; }
const SkRect& GetFilterRect() const { return filter_rect_; }
Expand Down Expand Up @@ -110,7 +111,7 @@ class Mutator {
explicit Mutator(const SkMatrix& matrix)
: type_(kTransform), matrix_(matrix) {}
explicit Mutator(const int& alpha) : type_(kOpacity), alpha_(alpha) {}
explicit Mutator(std::shared_ptr<const DlImageFilter> filter,
explicit Mutator(const std::shared_ptr<const DlImageFilter>& filter,
const SkRect& filter_rect)
: type_(kBackdropFilter),
filter_mutation_(
Expand Down Expand Up @@ -270,7 +271,7 @@ class EmbeddedViewParams {
MutatorsStack mutators_stack)
: matrix_(matrix),
size_points_(size_points),
mutators_stack_(mutators_stack) {
mutators_stack_(std::move(mutators_stack)) {
SkPath path;
SkRect starting_rect = SkRect::MakeSize(size_points);
path.addRect(starting_rect);
Expand All @@ -295,7 +296,7 @@ class EmbeddedViewParams {
// Pushes the stored DlImageFilter object to the mutators stack.
//
// `filter_rect` is in global coordinates.
void PushImageFilter(std::shared_ptr<const DlImageFilter> filter,
void PushImageFilter(const std::shared_ptr<const DlImageFilter>& filter,
const SkRect& filter_rect) {
mutators_stack_.PushBackdropFilter(filter, filter_rect);
}
Expand Down Expand Up @@ -344,7 +345,7 @@ class EmbedderViewSlice {

class DisplayListEmbedderViewSlice : public EmbedderViewSlice {
public:
DisplayListEmbedderViewSlice(SkRect view_bounds);
explicit DisplayListEmbedderViewSlice(SkRect view_bounds);
~DisplayListEmbedderViewSlice() override = default;

DlCanvas* canvas() override;
Expand Down Expand Up @@ -391,7 +392,7 @@ class ExternalViewEmbedder {
SkISize frame_size,
GrDirectContext* context,
double device_pixel_ratio,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) = 0;
const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) = 0;

virtual void PrerollCompositeEmbeddedView(
int64_t view_id,
Expand All @@ -402,7 +403,7 @@ class ExternalViewEmbedder {
// after it does any requisite tasks needed to bring itself to a valid state.
// Returns kSuccess if the view embedder is already in a valid state.
virtual PostPrerollResult PostPrerollAction(
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
return PostPrerollResult::kSuccess;
}

Expand Down Expand Up @@ -432,7 +433,7 @@ class ExternalViewEmbedder {
// returns false.
virtual void EndFrame(
bool should_resubmit_frame,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {}
const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {}

// Whether the embedder should support dynamic thread merging.
//
Expand Down Expand Up @@ -468,7 +469,7 @@ class ExternalViewEmbedder {
// See also: |PushVisitedPlatformView| for pushing platform view ids to the
// visited platform views list.
virtual void PushFilterToVisitedPlatformViews(
std::shared_ptr<const DlImageFilter> filter,
const std::shared_ptr<const DlImageFilter>& filter,
const SkRect& filter_rect) {}

private:
Expand Down
2 changes: 1 addition & 1 deletion flow/testing/mock_embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void MockViewEmbedder::BeginFrame(
SkISize frame_size,
GrDirectContext* context,
double device_pixel_ratio,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {}
const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {}

// |ExternalViewEmbedder|
void MockViewEmbedder::PrerollCompositeEmbeddedView(
Expand Down
10 changes: 5 additions & 5 deletions flow/testing/mock_embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class MockViewEmbedder : public ExternalViewEmbedder {
void CancelFrame() override;

// |ExternalViewEmbedder|
void BeginFrame(
SkISize frame_size,
GrDirectContext* context,
double device_pixel_ratio,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) override;
void BeginFrame(SkISize frame_size,
GrDirectContext* context,
double device_pixel_ratio,
const fml::RefPtr<fml::RasterThreadMerger>&
raster_thread_merger) override;

// |ExternalViewEmbedder|
void PrerollCompositeEmbeddedView(
Expand Down
65 changes: 39 additions & 26 deletions shell/common/rasterizer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,33 +89,36 @@ class MockExternalViewEmbedder : public ExternalViewEmbedder {
public:
MOCK_METHOD(DlCanvas*, GetRootCanvas, (), (override));
MOCK_METHOD(void, CancelFrame, (), (override));
MOCK_METHOD(void,
BeginFrame,
(SkISize frame_size,
GrDirectContext* context,
double device_pixel_ratio,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger),
(override));
MOCK_METHOD(
void,
BeginFrame,
(SkISize frame_size,
GrDirectContext* context,
double device_pixel_ratio,
const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger),
(override));
MOCK_METHOD(void,
PrerollCompositeEmbeddedView,
(int64_t view_id, std::unique_ptr<EmbeddedViewParams> params),
(override));
MOCK_METHOD(PostPrerollResult,
PostPrerollAction,
(fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger),
(override));
MOCK_METHOD(
PostPrerollResult,
PostPrerollAction,
(const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger),
(override));
MOCK_METHOD(DlCanvas*, CompositeEmbeddedView, (int64_t view_id), (override));
MOCK_METHOD(void,
SubmitFrame,
(GrDirectContext * context,
const std::shared_ptr<impeller::AiksContext>& aiks_context,
std::unique_ptr<SurfaceFrame> frame),
(override));
MOCK_METHOD(void,
EndFrame,
(bool should_resubmit_frame,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger),
(override));
MOCK_METHOD(
void,
EndFrame,
(bool should_resubmit_frame,
const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger),
(override));
MOCK_METHOD(bool, SupportsDynamicThreadMerging, (), (override));
};
} // namespace
Expand Down Expand Up @@ -199,7 +202,8 @@ TEST(RasterizerTest,
framebuffer_info.supports_readback = true;

auto surface_frame = std::make_unique<SurfaceFrame>(
/*surface=*/nullptr, framebuffer_info,
/*surface=*/
nullptr, framebuffer_info,
/*submit_callback=*/[](const SurfaceFrame&, DlCanvas*) { return true; },
/*frame_size=*/SkISize::Make(800, 600));
EXPECT_CALL(*surface, AllowsDrawingWhenGpuDisabled()).WillOnce(Return(true));
Expand Down Expand Up @@ -271,7 +275,8 @@ TEST(
SurfaceFrame::FramebufferInfo framebuffer_info;
framebuffer_info.supports_readback = true;
auto surface_frame = std::make_unique<SurfaceFrame>(
/*surface=*/nullptr, framebuffer_info,
/*surface=*/
nullptr, framebuffer_info,
/*submit_callback=*/[](const SurfaceFrame&, DlCanvas*) { return true; },
/*frame_size=*/SkISize::Make(800, 600));
EXPECT_CALL(*surface, AllowsDrawingWhenGpuDisabled()).WillOnce(Return(true));
Expand Down Expand Up @@ -343,7 +348,8 @@ TEST(
framebuffer_info.supports_readback = true;

auto surface_frame = std::make_unique<SurfaceFrame>(
/*surface=*/nullptr, framebuffer_info,
/*surface=*/
nullptr, framebuffer_info,
/*submit_callback=*/[](const SurfaceFrame&, DlCanvas*) { return true; },
/*frame_size=*/SkISize::Make(800, 600));
EXPECT_CALL(*surface, AllowsDrawingWhenGpuDisabled()).WillOnce(Return(true));
Expand Down Expand Up @@ -412,11 +418,13 @@ TEST(RasterizerTest,
framebuffer_info.supports_readback = true;

auto surface_frame1 = std::make_unique<SurfaceFrame>(
/*surface=*/nullptr, framebuffer_info,
/*surface=*/
nullptr, framebuffer_info,
/*submit_callback=*/[](const SurfaceFrame&, DlCanvas*) { return true; },
/*frame_size=*/SkISize::Make(800, 600));
auto surface_frame2 = std::make_unique<SurfaceFrame>(
/*surface=*/nullptr, framebuffer_info,
/*surface=*/
nullptr, framebuffer_info,
/*submit_callback=*/[](const SurfaceFrame&, DlCanvas*) { return true; },
/*frame_size=*/SkISize::Make(800, 600));
EXPECT_CALL(*surface, AllowsDrawingWhenGpuDisabled())
Expand Down Expand Up @@ -645,7 +653,8 @@ TEST(RasterizerTest,
SurfaceFrame::FramebufferInfo framebuffer_info;
framebuffer_info.supports_readback = true;
auto surface_frame = std::make_unique<SurfaceFrame>(
/*surface=*/nullptr, /*framebuffer_info=*/framebuffer_info,
/*surface=*/
nullptr, /*framebuffer_info=*/framebuffer_info,
/*submit_callback=*/[](const SurfaceFrame&, DlCanvas*) { return true; },
/*frame_size=*/SkISize::Make(800, 600));
EXPECT_CALL(*surface, AllowsDrawingWhenGpuDisabled()).WillOnce(Return(true));
Expand Down Expand Up @@ -704,7 +713,8 @@ TEST(
framebuffer_info.supports_readback = true;

auto surface_frame = std::make_unique<SurfaceFrame>(
/*surface=*/nullptr, /*framebuffer_info=*/framebuffer_info,
/*surface=*/
nullptr, /*framebuffer_info=*/framebuffer_info,
/*submit_callback=*/[](const SurfaceFrame&, DlCanvas*) { return true; },
/*frame_size=*/SkISize::Make(800, 600));
EXPECT_CALL(*surface, AllowsDrawingWhenGpuDisabled()).WillOnce(Return(true));
Expand Down Expand Up @@ -764,7 +774,8 @@ TEST(
framebuffer_info.supports_readback = true;

auto surface_frame = std::make_unique<SurfaceFrame>(
/*surface=*/nullptr, /*framebuffer_info=*/framebuffer_info,
/*surface=*/
nullptr, /*framebuffer_info=*/framebuffer_info,
/*submit_callback=*/[](const SurfaceFrame&, DlCanvas*) { return true; },
/*frame_size=*/SkISize::Make(800, 600));
EXPECT_CALL(*surface, AllowsDrawingWhenGpuDisabled()).WillOnce(Return(false));
Expand Down Expand Up @@ -823,7 +834,8 @@ TEST(
framebuffer_info.supports_readback = true;

auto surface_frame = std::make_unique<SurfaceFrame>(
/*surface=*/nullptr, /*framebuffer_info=*/framebuffer_info,
/*surface=*/
nullptr, /*framebuffer_info=*/framebuffer_info,
/*submit_callback=*/[](const SurfaceFrame&, DlCanvas*) { return true; },
/*frame_size=*/SkISize::Make(800, 600));
EXPECT_CALL(*surface, AllowsDrawingWhenGpuDisabled()).WillOnce(Return(false));
Expand Down Expand Up @@ -945,7 +957,8 @@ TEST(RasterizerTest,
SurfaceFrame::FramebufferInfo framebuffer_info;
framebuffer_info.supports_readback = true;
return std::make_unique<SurfaceFrame>(
/*surface=*/nullptr, framebuffer_info,
/*surface=*/
nullptr, framebuffer_info,
/*submit_callback=*/
[](const SurfaceFrame& frame, DlCanvas*) { return true; },
/*frame_size=*/SkISize::Make(800, 600));
Expand Down
8 changes: 4 additions & 4 deletions shell/common/shell_test_external_view_embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void ShellTestExternalViewEmbedder::BeginFrame(
SkISize frame_size,
GrDirectContext* context,
double device_pixel_ratio,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
visited_platform_views_.clear();
mutators_stacks_.clear();
current_composition_params_.clear();
Expand All @@ -61,7 +61,7 @@ void ShellTestExternalViewEmbedder::PrerollCompositeEmbeddedView(

// |ExternalViewEmbedder|
PostPrerollResult ShellTestExternalViewEmbedder::PostPrerollAction(
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
FML_DCHECK(raster_thread_merger);
return post_preroll_result_;
}
Expand All @@ -73,7 +73,7 @@ void ShellTestExternalViewEmbedder::PushVisitedPlatformView(int64_t view_id) {

// |ExternalViewEmbedder|
void ShellTestExternalViewEmbedder::PushFilterToVisitedPlatformViews(
std::shared_ptr<const DlImageFilter> filter,
const std::shared_ptr<const DlImageFilter>& filter,
const SkRect& filter_rect) {
for (int64_t id : visited_platform_views_) {
EmbeddedViewParams params = current_composition_params_[id];
Expand Down Expand Up @@ -109,7 +109,7 @@ void ShellTestExternalViewEmbedder::SubmitFrame(
// |ExternalViewEmbedder|
void ShellTestExternalViewEmbedder::EndFrame(
bool should_resubmit_frame,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
end_frame_call_back_(should_resubmit_frame, raster_thread_merger);
}

Expand Down
21 changes: 11 additions & 10 deletions shell/common/shell_test_external_view_embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ class ShellTestExternalViewEmbedder final : public ExternalViewEmbedder {
void CancelFrame() override;

// |ExternalViewEmbedder|
void BeginFrame(
SkISize frame_size,
GrDirectContext* context,
double device_pixel_ratio,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) override;
void BeginFrame(SkISize frame_size,
GrDirectContext* context,
double device_pixel_ratio,
const fml::RefPtr<fml::RasterThreadMerger>&
raster_thread_merger) override;

// |ExternalViewEmbedder|
void PrerollCompositeEmbeddedView(
Expand All @@ -59,7 +59,8 @@ class ShellTestExternalViewEmbedder final : public ExternalViewEmbedder {

// |ExternalViewEmbedder|
PostPrerollResult PostPrerollAction(
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) override;
const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger)
override;

// |ExternalViewEmbedder|
DlCanvas* CompositeEmbeddedView(int64_t view_id) override;
Expand All @@ -69,7 +70,7 @@ class ShellTestExternalViewEmbedder final : public ExternalViewEmbedder {

// |ExternalViewEmbedder|
void PushFilterToVisitedPlatformViews(
std::shared_ptr<const DlImageFilter> filter,
const std::shared_ptr<const DlImageFilter>& filter,
const SkRect& filter_rect) override;

// |ExternalViewEmbedder|
Expand All @@ -78,9 +79,9 @@ class ShellTestExternalViewEmbedder final : public ExternalViewEmbedder {
std::unique_ptr<SurfaceFrame> frame) override;

// |ExternalViewEmbedder|
void EndFrame(
bool should_resubmit_frame,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) override;
void EndFrame(bool should_resubmit_frame,
const fml::RefPtr<fml::RasterThreadMerger>&
raster_thread_merger) override;

// |ExternalViewEmbedder|
DlCanvas* GetRootCanvas() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ AndroidExternalViewEmbedder::CreateSurfaceIfNeeded(GrDirectContext* context,

// |ExternalViewEmbedder|
PostPrerollResult AndroidExternalViewEmbedder::PostPrerollAction(
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
if (!FrameHasPlatformLayers()) {
return PostPrerollResult::kSuccess;
}
Expand Down Expand Up @@ -260,7 +260,7 @@ void AndroidExternalViewEmbedder::BeginFrame(
SkISize frame_size,
GrDirectContext* context,
double device_pixel_ratio,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
Reset();

// The surface size changed. Therefore, destroy existing surfaces as
Expand All @@ -286,7 +286,7 @@ void AndroidExternalViewEmbedder::CancelFrame() {
// |ExternalViewEmbedder|
void AndroidExternalViewEmbedder::EndFrame(
bool should_resubmit_frame,
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) {
const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger) {
surface_pool_->RecycleLayers();
// JNI method must be called on the platform thread.
if (raster_thread_merger->IsOnPlatformThread()) {
Expand Down
Loading

0 comments on commit ea42577

Please sign in to comment.