Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6db71f2

Browse files
[Impeller] dont accidentally copy shared ptr. (#49731)
Copying the shared ptr when we don't need to results in us incrementing/decrementing the ref count which isn't free.
1 parent f7cf731 commit 6db71f2

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

impeller/entity/contents/solid_color_contents.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "impeller/entity/contents/clip_contents.h"
88
#include "impeller/entity/contents/content_context.h"
99
#include "impeller/entity/entity.h"
10+
#include "impeller/entity/geometry/geometry.h"
1011
#include "impeller/geometry/path.h"
1112
#include "impeller/renderer/render_pass.h"
1213

@@ -38,7 +39,7 @@ std::optional<Rect> SolidColorContents::GetCoverage(
3839
return std::nullopt;
3940
}
4041

41-
auto geometry = GetGeometry();
42+
const std::shared_ptr<Geometry>& geometry = GetGeometry();
4243
if (geometry == nullptr) {
4344
return std::nullopt;
4445
}

impeller/entity/contents/vertices_contents.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include "impeller/entity/contents/content_context.h"
88
#include "impeller/entity/contents/filters/color_filter_contents.h"
9+
#include "impeller/entity/geometry/geometry.h"
10+
#include "impeller/entity/geometry/vertices_geometry.h"
911
#include "impeller/entity/position_color.vert.h"
1012
#include "impeller/entity/vertices.frag.h"
1113
#include "impeller/geometry/color.h"
@@ -122,7 +124,7 @@ bool VerticesUVContents::Render(const ContentContext& renderer,
122124
Command cmd;
123125
DEBUG_COMMAND_INFO(cmd, "VerticesUV");
124126
auto& host_buffer = renderer.GetTransientsBuffer();
125-
auto geometry = parent_.GetGeometry();
127+
const std::shared_ptr<Geometry>& geometry = parent_.GetGeometry();
126128

127129
auto coverage = src_contents->GetCoverage(Entity{});
128130
if (!coverage.has_value()) {
@@ -176,7 +178,7 @@ bool VerticesColorContents::Render(const ContentContext& renderer,
176178
Command cmd;
177179
DEBUG_COMMAND_INFO(cmd, "VerticesColors");
178180
auto& host_buffer = renderer.GetTransientsBuffer();
179-
auto geometry = parent_.GetGeometry();
181+
const std::shared_ptr<VerticesGeometry>& geometry = parent_.GetGeometry();
180182

181183
auto geometry_result =
182184
geometry->GetPositionColorBuffer(renderer, entity, pass);

impeller/entity/geometry/round_rect_geometry.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#include <algorithm>
6-
75
#include "flutter/impeller/entity/geometry/round_rect_geometry.h"
86

9-
#include "flutter/impeller/entity/geometry/line_geometry.h"
10-
117
namespace impeller {
128

139
RoundRectGeometry::RoundRectGeometry(const Rect& bounds, const Size& radii)

0 commit comments

Comments
 (0)