Removed instances of unnecessary values (flutter/engine#36221)

This commit is contained in:
gaaclarke
2022-09-26 14:28:04 -07:00
committed by GitHub
parent e32aa7f1ff
commit e41c775200
290 changed files with 1191 additions and 1045 deletions

View File

@@ -10,7 +10,9 @@ readability-identifier-naming,\
-clang-analyzer-nullability.NullPassedToNonnull,\
-clang-analyzer-nullability.NullablePassedToNonnull,\
-clang-analyzer-nullability.NullReturnedFromNonnull,\
-clang-analyzer-nullability.NullableReturnedFromNonnull"
-clang-analyzer-nullability.NullableReturnedFromNonnull,\
performance-move-const-arg,\
performance-unnecessary-value-param"
# Only warnings treated as errors are reported
# in the "ci/lint.sh" script and pre-push git hook.

View File

@@ -8,6 +8,7 @@
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include "flutter/fml/base32.h"
#include "flutter/fml/file.h"
@@ -74,7 +75,7 @@ void PersistentCache::ResetCacheForProcess() {
}
void PersistentCache::SetCacheDirectoryPath(std::string path) {
cache_base_path_ = path;
cache_base_path_ = std::move(path);
}
bool PersistentCache::Purge() {
@@ -343,10 +344,11 @@ sk_sp<SkData> PersistentCache::load(const SkData& key) {
return result;
}
static void PersistentCacheStore(fml::RefPtr<fml::TaskRunner> worker,
std::shared_ptr<fml::UniqueFD> cache_directory,
std::string key,
std::unique_ptr<fml::Mapping> value) {
static void PersistentCacheStore(
const fml::RefPtr<fml::TaskRunner>& worker,
const std::shared_ptr<fml::UniqueFD>& cache_directory,
std::string key,
std::unique_ptr<fml::Mapping> value) {
// The static leak checker gets confused by the use of fml::MakeCopyable.
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
auto task = fml::MakeCopyable([cache_directory, //
@@ -440,13 +442,13 @@ void PersistentCache::DumpSkp(const SkData& data) {
}
void PersistentCache::AddWorkerTaskRunner(
fml::RefPtr<fml::TaskRunner> task_runner) {
const fml::RefPtr<fml::TaskRunner>& task_runner) {
std::scoped_lock lock(worker_task_runners_mutex_);
worker_task_runners_.insert(task_runner);
}
void PersistentCache::RemoveWorkerTaskRunner(
fml::RefPtr<fml::TaskRunner> task_runner) {
const fml::RefPtr<fml::TaskRunner>& task_runner) {
std::scoped_lock lock(worker_task_runners_mutex_);
auto found = worker_task_runners_.find(task_runner);
if (found != worker_task_runners_.end()) {
@@ -467,7 +469,7 @@ fml::RefPtr<fml::TaskRunner> PersistentCache::GetWorkerTaskRunner() const {
void PersistentCache::SetAssetManager(std::shared_ptr<AssetManager> value) {
TRACE_EVENT_INSTANT0("flutter", "PersistentCache::SetAssetManager");
asset_manager_ = value;
asset_manager_ = std::move(value);
}
std::vector<std::unique_ptr<fml::Mapping>>

View File

@@ -68,9 +68,9 @@ class PersistentCache : public GrContextOptions::PersistentCache {
~PersistentCache() override;
void AddWorkerTaskRunner(fml::RefPtr<fml::TaskRunner> task_runner);
void AddWorkerTaskRunner(const fml::RefPtr<fml::TaskRunner>& task_runner);
void RemoveWorkerTaskRunner(fml::RefPtr<fml::TaskRunner> task_runner);
void RemoveWorkerTaskRunner(const fml::RefPtr<fml::TaskRunner>& task_runner);
// Whether Skia tries to store any shader into this persistent cache after
// |ResetStoredNewShaders| is called. This flag is usually reset before each

View File

@@ -16,7 +16,7 @@ Texture::~Texture() = default;
TextureRegistry::TextureRegistry() = default;
void TextureRegistry::RegisterTexture(std::shared_ptr<Texture> texture) {
void TextureRegistry::RegisterTexture(const std::shared_ptr<Texture>& texture) {
if (!texture) {
return;
}

View File

@@ -62,7 +62,7 @@ class TextureRegistry {
TextureRegistry();
// Called from raster thread.
void RegisterTexture(std::shared_ptr<Texture> texture);
void RegisterTexture(const std::shared_ptr<Texture>& texture);
// Called from raster thread.
void RegisterContextListener(uintptr_t id,

View File

@@ -897,7 +897,7 @@ void DisplayListBuilder::drawImage(const sk_sp<DlImage> image,
: Push<DrawImageOp>(0, 1, std::move(image), point, sampling);
CheckLayerOpacityCompatibility(render_with_attributes);
}
void DisplayListBuilder::drawImage(const sk_sp<DlImage> image,
void DisplayListBuilder::drawImage(const sk_sp<DlImage>& image,
const SkPoint point,
DlImageSampling sampling,
const DlPaint* paint) {
@@ -919,7 +919,7 @@ void DisplayListBuilder::drawImageRect(const sk_sp<DlImage> image,
render_with_attributes, constraint);
CheckLayerOpacityCompatibility(render_with_attributes);
}
void DisplayListBuilder::drawImageRect(const sk_sp<DlImage> image,
void DisplayListBuilder::drawImageRect(const sk_sp<DlImage>& image,
const SkRect& src,
const SkRect& dst,
DlImageSampling sampling,
@@ -944,7 +944,7 @@ void DisplayListBuilder::drawImageNine(const sk_sp<DlImage> image,
: Push<DrawImageNineOp>(0, 1, std::move(image), center, dst, filter);
CheckLayerOpacityCompatibility(render_with_attributes);
}
void DisplayListBuilder::drawImageNine(const sk_sp<DlImage> image,
void DisplayListBuilder::drawImageNine(const sk_sp<DlImage>& image,
const SkIRect& center,
const SkRect& dst,
DlFilterMode filter,
@@ -1017,7 +1017,7 @@ void DisplayListBuilder::drawAtlas(const sk_sp<DlImage> atlas,
// of the transforms and texture rectangles.
UpdateLayerOpacityCompatibility(false);
}
void DisplayListBuilder::drawAtlas(const sk_sp<DlImage> atlas,
void DisplayListBuilder::drawAtlas(const sk_sp<DlImage>& atlas,
const SkRSXform xform[],
const SkRect tex[],
const DlColor colors[],

View File

@@ -275,7 +275,7 @@ class DisplayListBuilder final : public virtual Dispatcher,
const SkPoint point,
DlImageSampling sampling,
bool render_with_attributes) override;
void drawImage(const sk_sp<DlImage> image,
void drawImage(const sk_sp<DlImage>& image,
const SkPoint point,
DlImageSampling sampling,
const DlPaint* paint = nullptr);
@@ -287,7 +287,7 @@ class DisplayListBuilder final : public virtual Dispatcher,
bool render_with_attributes,
SkCanvas::SrcRectConstraint constraint =
SkCanvas::SrcRectConstraint::kFast_SrcRectConstraint) override;
void drawImageRect(const sk_sp<DlImage> image,
void drawImageRect(const sk_sp<DlImage>& image,
const SkRect& src,
const SkRect& dst,
DlImageSampling sampling,
@@ -299,7 +299,7 @@ class DisplayListBuilder final : public virtual Dispatcher,
const SkRect& dst,
DlFilterMode filter,
bool render_with_attributes) override;
void drawImageNine(const sk_sp<DlImage> image,
void drawImageNine(const sk_sp<DlImage>& image,
const SkIRect& center,
const SkRect& dst,
DlFilterMode filter,
@@ -318,7 +318,7 @@ class DisplayListBuilder final : public virtual Dispatcher,
DlImageSampling sampling,
const SkRect* cullRect,
bool render_with_attributes) override;
void drawAtlas(const sk_sp<DlImage> atlas,
void drawAtlas(const sk_sp<DlImage>& atlas,
const SkRSXform xform[],
const SkRect tex[],
const DlColor colors[],

View File

@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <utility>
#include "flutter/display_list/display_list.h"
#include "flutter/display_list/display_list_canvas_dispatcher.h"
#include "flutter/display_list/display_list_canvas_recorder.h"
@@ -239,7 +241,8 @@ static void EmptyDlRenderer(DisplayListBuilder&) {}
class RenderSurface {
public:
explicit RenderSurface(sk_sp<SkSurface> surface) : surface_(surface) {
explicit RenderSurface(sk_sp<SkSurface> surface)
: surface_(std::move(surface)) {
EXPECT_EQ(canvas()->save(), 1);
}
~RenderSurface() { sk_free(addr_); }
@@ -597,10 +600,10 @@ class TestParameters {
class CaseParameters {
public:
explicit CaseParameters(std::string info)
: CaseParameters(info, EmptyCvRenderer, EmptyDlRenderer) {}
: CaseParameters(std::move(info), EmptyCvRenderer, EmptyDlRenderer) {}
CaseParameters(std::string info, CvSetup cv_setup, DlRenderer dl_setup)
: CaseParameters(info,
CaseParameters(std::string info, CvSetup& cv_setup, DlRenderer& dl_setup)
: CaseParameters(std::move(info),
cv_setup,
dl_setup,
EmptyCvRenderer,
@@ -611,15 +614,15 @@ class CaseParameters {
false) {}
CaseParameters(std::string info,
CvSetup cv_setup,
DlRenderer dl_setup,
CvRenderer cv_restore,
DlRenderer dl_restore,
CvSetup& cv_setup,
DlRenderer& dl_setup,
CvRenderer& cv_restore,
DlRenderer& dl_restore,
DlColor bg,
bool has_diff_clip,
bool has_mutating_save_layer,
bool fuzzy_compare_components)
: info_(info),
: info_(std::move(info)),
bg_(bg),
cv_setup_(cv_setup),
dl_setup_(dl_setup),
@@ -629,8 +632,8 @@ class CaseParameters {
has_mutating_save_layer_(has_mutating_save_layer),
fuzzy_compare_components_(fuzzy_compare_components) {}
CaseParameters with_restore(CvRenderer cv_restore,
DlRenderer dl_restore,
CaseParameters with_restore(CvRenderer& cv_restore,
DlRenderer& dl_restore,
bool mutating_layer,
bool fuzzy_compare_components = false) {
return CaseParameters(info_, cv_setup_, dl_setup_, cv_restore, dl_restore,
@@ -1945,9 +1948,9 @@ class CanvasCompareTester {
}
static void checkGroupOpacity(const RenderEnvironment& env,
sk_sp<DisplayList> display_list,
const sk_sp<DisplayList>& display_list,
const SkPixmap* ref_pixmap,
const std::string info,
const std::string& info,
DlColor bg) {
SkScalar opacity = 128.0 / 255.0;
@@ -2002,7 +2005,7 @@ class CanvasCompareTester {
static void checkPixels(const SkPixmap* ref_pixels,
const SkRect ref_bounds,
const std::string info,
const std::string& info,
const DlColor bg) {
uint32_t untouched = bg.premultipliedArgb();
int pixels_touched = 0;
@@ -2026,7 +2029,7 @@ class CanvasCompareTester {
static void quickCompareToReference(const SkPixmap* ref_pixels,
const SkPixmap* test_pixels,
bool should_match,
const std::string info) {
const std::string& info) {
ASSERT_EQ(test_pixels->width(), ref_pixels->width()) << info;
ASSERT_EQ(test_pixels->height(), ref_pixels->height()) << info;
ASSERT_EQ(test_pixels->info().bytesPerPixel(), 4) << info;
@@ -2050,7 +2053,7 @@ class CanvasCompareTester {
static void compareToReference(const SkPixmap* test_pixels,
const SkPixmap* ref_pixels,
const std::string info,
const std::string& info,
SkRect* bounds,
const BoundsTolerance* tolerance,
const DlColor bg,
@@ -2121,7 +2124,7 @@ class CanvasCompareTester {
ASSERT_EQ(pixels_different, 0) << info;
}
static void showBoundsOverflow(std::string info,
static void showBoundsOverflow(const std::string& info,
SkIRect& bounds,
const BoundsTolerance* tolerance,
int pixLeft,
@@ -2186,7 +2189,7 @@ class CanvasCompareTester {
static const DlImageColorSource kTestImageColorSource;
static sk_sp<SkTextBlob> MakeTextBlob(std::string string,
static sk_sp<SkTextBlob> MakeTextBlob(const std::string& string,
SkScalar font_height) {
SkFont font(SkTypeface::MakeFromName("ahem", SkFontStyle::Normal()),
font_height);

View File

@@ -131,7 +131,7 @@ void testNotEquals(DlMaskFilter* a, DlMaskFilter* b) {
ASSERT_TRUE(NotEquals(b, a));
}
void testEquals(std::shared_ptr<const DlMaskFilter> a, DlMaskFilter* b) {
void testEquals(const std::shared_ptr<const DlMaskFilter>& a, DlMaskFilter* b) {
// a and b have the same nullness or values
ASSERT_TRUE(Equals(a, b));
ASSERT_FALSE(NotEquals(a, b));
@@ -139,7 +139,8 @@ void testEquals(std::shared_ptr<const DlMaskFilter> a, DlMaskFilter* b) {
ASSERT_FALSE(NotEquals(b, a));
}
void testNotEquals(std::shared_ptr<const DlMaskFilter> a, DlMaskFilter* b) {
void testNotEquals(const std::shared_ptr<const DlMaskFilter>& a,
DlMaskFilter* b) {
// a and b do not have the same nullness or values
ASSERT_FALSE(Equals(a, b));
ASSERT_TRUE(NotEquals(a, b));
@@ -147,8 +148,8 @@ void testNotEquals(std::shared_ptr<const DlMaskFilter> a, DlMaskFilter* b) {
ASSERT_TRUE(NotEquals(b, a));
}
void testEquals(std::shared_ptr<const DlMaskFilter> a,
std::shared_ptr<const DlMaskFilter> b) {
void testEquals(const std::shared_ptr<const DlMaskFilter>& a,
const std::shared_ptr<const DlMaskFilter>& b) {
// a and b have the same nullness or values
ASSERT_TRUE(Equals(a, b));
ASSERT_FALSE(NotEquals(a, b));
@@ -156,8 +157,8 @@ void testEquals(std::shared_ptr<const DlMaskFilter> a,
ASSERT_FALSE(NotEquals(b, a));
}
void testNotEquals(std::shared_ptr<const DlMaskFilter> a,
std::shared_ptr<const DlMaskFilter> b) {
void testNotEquals(const std::shared_ptr<const DlMaskFilter>& a,
const std::shared_ptr<const DlMaskFilter>& b) {
// a and b do not have the same nullness or values
ASSERT_FALSE(Equals(a, b));
ASSERT_TRUE(NotEquals(a, b));

View File

@@ -5,6 +5,7 @@
#include <memory>
#include <string>
#include <unordered_set>
#include <utility>
#include <vector>
#include "flutter/display_list/display_list.h"
@@ -591,7 +592,7 @@ TEST(DisplayList, DisplayListTransformResetHandling) {
}
TEST(DisplayList, SingleOpsMightSupportGroupOpacityWithOrWithoutBlendMode) {
auto run_tests = [](std::string name,
auto run_tests = [](const std::string& name,
void build(DisplayListBuilder & builder),
bool expect_for_op, bool expect_with_kSrc) {
{
@@ -783,12 +784,12 @@ class SaveLayerOptionsExpector : public virtual Dispatcher,
public IgnoreTransformDispatchHelper,
public IgnoreDrawDispatchHelper {
public:
explicit SaveLayerOptionsExpector(SaveLayerOptions expected) {
explicit SaveLayerOptionsExpector(const SaveLayerOptions& expected) {
expected_.push_back(expected);
}
explicit SaveLayerOptionsExpector(std::vector<SaveLayerOptions> expected)
: expected_(expected) {}
: expected_(std::move(expected)) {}
void saveLayer(const SkRect* bounds,
const SaveLayerOptions options,
@@ -1541,10 +1542,10 @@ TEST(DisplayList, FlatDrawPointsProducesBounds) {
}
}
static void test_rtree(sk_sp<const DlRTree> rtree,
static void test_rtree(const sk_sp<const DlRTree>& rtree,
const SkRect& query,
std::vector<SkRect> expected_rects,
std::vector<int> expected_indices) {
const std::vector<int>& expected_indices) {
std::vector<int> indices;
rtree->search(query, &indices);
EXPECT_EQ(indices, expected_indices);

View File

@@ -5,6 +5,7 @@
#include "flutter/flow/compositor_context.h"
#include <optional>
#include <utility>
#include "flutter/flow/layers/layer_tree.h"
#include "third_party/skia/include/core/SkCanvas.h"
@@ -106,7 +107,7 @@ CompositorContext::ScopedFrame::ScopedFrame(
root_surface_transformation_(root_surface_transformation),
instrumentation_enabled_(instrumentation_enabled),
surface_supports_readback_(surface_supports_readback),
raster_thread_merger_(raster_thread_merger) {
raster_thread_merger_(std::move(raster_thread_merger)) {
context_.BeginFrame(*this, instrumentation_enabled_);
}

View File

@@ -35,7 +35,7 @@ void DiffContext::EndSubtree() {
if (state_.has_filter_bounds_adjustment) {
filter_bounds_adjustment_stack_.pop_back();
}
state_ = std::move(state_stack_.back());
state_ = state_stack_.back();
state_stack_.pop_back();
}
@@ -54,7 +54,8 @@ void DiffContext::SetTransform(const SkMatrix& transform) {
state_.transform_override = transform;
}
void DiffContext::PushFilterBoundsAdjustment(FilterBoundsAdjustment filter) {
void DiffContext::PushFilterBoundsAdjustment(
const FilterBoundsAdjustment& filter) {
FML_DCHECK(state_.has_filter_bounds_adjustment == false);
state_.has_filter_bounds_adjustment = true;
filter_bounds_adjustment_stack_.push_back(filter);

View File

@@ -81,7 +81,7 @@ class DiffContext {
// Pushes filter bounds adjustment to current subtree. Every layer in this
// subtree will have bounds adjusted by this function.
void PushFilterBoundsAdjustment(FilterBoundsAdjustment filter);
void PushFilterBoundsAdjustment(const FilterBoundsAdjustment& filter);
// Returns transform matrix for current subtree
const SkMatrix& GetTransform() const { return state_.transform; }

View File

@@ -100,7 +100,7 @@ void MutatorsStack::PushOpacity(const int& alpha) {
};
void MutatorsStack::PushBackdropFilter(
std::shared_ptr<const DlImageFilter> filter) {
const std::shared_ptr<const DlImageFilter>& filter) {
std::shared_ptr<Mutator> element = std::make_shared<Mutator>(filter);
vector_.push_back(element);
};

View File

@@ -154,7 +154,7 @@ class MutatorsStack {
void PushClipPath(const SkPath& path);
void PushTransform(const SkMatrix& matrix);
void PushOpacity(const int& alpha);
void PushBackdropFilter(std::shared_ptr<const DlImageFilter> filter);
void PushBackdropFilter(const std::shared_ptr<const DlImageFilter>& filter);
// Removes the `Mutator` on the top of the stack
// and destroys it.

View File

@@ -209,7 +209,7 @@ TEST_F(ClipPathLayerTest, PartiallyContainedChild) {
static bool ReadbackResult(PrerollContext* context,
Clip clip_behavior,
std::shared_ptr<Layer> child,
const std::shared_ptr<Layer>& child,
bool before) {
const SkMatrix initial_matrix = SkMatrix();
const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);

View File

@@ -205,7 +205,7 @@ TEST_F(ClipRectLayerTest, PartiallyContainedChild) {
static bool ReadbackResult(PrerollContext* context,
Clip clip_behavior,
std::shared_ptr<Layer> child,
const std::shared_ptr<Layer>& child,
bool before) {
const SkMatrix initial_matrix = SkMatrix();
const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);

View File

@@ -209,7 +209,7 @@ TEST_F(ClipRRectLayerTest, PartiallyContainedChild) {
static bool ReadbackResult(PrerollContext* context,
Clip clip_behavior,
std::shared_ptr<Layer> child,
const std::shared_ptr<Layer>& child,
bool before) {
const SkMatrix initial_matrix = SkMatrix();
const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);

View File

@@ -173,7 +173,7 @@ void LayerTree::Paint(CompositorContext::ScopedFrame& frame,
sk_sp<DisplayList> LayerTree::Flatten(
const SkRect& bounds,
std::shared_ptr<TextureRegistry> texture_registry,
const std::shared_ptr<TextureRegistry>& texture_registry,
GrDirectContext* gr_context) {
TRACE_EVENT0("flutter", "LayerTree::Flatten");

View File

@@ -44,7 +44,7 @@ class LayerTree {
sk_sp<DisplayList> Flatten(
const SkRect& bounds,
std::shared_ptr<TextureRegistry> texture_registry = nullptr,
const std::shared_ptr<TextureRegistry>& texture_registry = nullptr,
GrDirectContext* gr_context = nullptr);
Layer* root_layer() const { return root_layer_.get(); }

View File

@@ -33,7 +33,7 @@ static sk_sp<SkSurface> CreateSnapshotSurface(GrDirectContext* surface_context,
/// Returns a buffer containing a snapshot of the surface.
///
/// If compressed is true the data is encoded as PNG.
static sk_sp<SkData> GetRasterData(sk_sp<SkSurface> offscreen_surface,
static sk_sp<SkData> GetRasterData(const sk_sp<SkSurface>& offscreen_surface,
bool compressed) {
// Prepare an image from the surface, this image may potentially be on th GPU.
auto potentially_gpu_snapshot = offscreen_surface->makeImageSnapshot();

View File

@@ -355,7 +355,7 @@ TEST_F(PhysicalShapeLayerTest, ShadowNotDependsPathSize) {
static bool ReadbackResult(PrerollContext* context,
Clip clip_behavior,
std::shared_ptr<Layer> child,
const std::shared_ptr<Layer>& child,
bool before) {
const SkMatrix initial_matrix = SkMatrix();
const SkRect layer_bounds = SkRect::MakeXYWH(0.5, 1.0, 5.0, 6.0);

View File

@@ -5,6 +5,7 @@
#include "flutter/flow/skia_gpu_object.h"
#include <future>
#include <utility>
#include "flutter/fml/message_loop.h"
#include "flutter/fml/synchronization/waitable_event.h"
@@ -20,7 +21,7 @@ class TestSkObject : public SkRefCnt {
public:
TestSkObject(std::shared_ptr<fml::AutoResetWaitableEvent> latch,
fml::TaskQueueId* dtor_task_queue_id)
: latch_(latch), dtor_task_queue_id_(dtor_task_queue_id) {}
: latch_(std::move(latch)), dtor_task_queue_id_(dtor_task_queue_id) {}
virtual ~TestSkObject() {
if (dtor_task_queue_id_) {
@@ -38,10 +39,10 @@ class TestResourceContext : public TestSkObject {
public:
TestResourceContext(std::shared_ptr<fml::AutoResetWaitableEvent> latch,
fml::TaskQueueId* dtor_task_queue_id)
: TestSkObject(latch, dtor_task_queue_id) {}
: TestSkObject(std::move(latch), dtor_task_queue_id) {}
~TestResourceContext() = default;
void performDeferredCleanup(std::chrono::milliseconds msNotUsed) {}
void deleteBackendTexture(GrBackendTexture texture) {}
void deleteBackendTexture(const GrBackendTexture& texture) {}
};
class SkiaGpuObjectTest : public ThreadTest {

View File

@@ -5,6 +5,7 @@
#include "flutter/flow/surface_frame.h"
#include <limits>
#include <utility>
#include "flutter/fml/logging.h"
#include "flutter/fml/trace_event.h"
@@ -18,8 +19,8 @@ SurfaceFrame::SurfaceFrame(sk_sp<SkSurface> surface,
SkISize frame_size,
std::unique_ptr<GLContextResult> context_result,
bool display_list_fallback)
: surface_(surface),
framebuffer_info_(std::move(framebuffer_info)),
: surface_(std::move(surface)),
framebuffer_info_(framebuffer_info),
submit_callback_(submit_callback),
context_result_(std::move(context_result)) {
FML_DCHECK(submit_callback_);

View File

@@ -3,6 +3,8 @@
// found in the LICENSE file.
#include "diff_context_test.h"
#include <utility>
#include "flutter/display_list/display_list_builder.h"
namespace flutter {
@@ -42,7 +44,8 @@ std::shared_ptr<DisplayListLayer> DiffContextTest::CreateDisplayListLayer(
sk_sp<DisplayList> display_list,
const SkPoint& offset) {
return std::make_shared<DisplayListLayer>(
offset, SkiaGPUObject(display_list, unref_queue()), false, false);
offset, SkiaGPUObject(std::move(display_list), unref_queue()), false,
false);
}
std::shared_ptr<ContainerLayer> DiffContextTest::CreateContainerLayer(

View File

@@ -4,14 +4,16 @@
#include "flutter/flow/testing/mock_layer.h"
#include <utility>
#include "flutter/flow/layers/container_layer.h"
#include "flutter/flow/layers/layer.h"
#include "flutter/flow/testing/mock_raster_cache.h"
namespace flutter {
namespace testing {
MockLayer::MockLayer(SkPath path, SkPaint paint)
: fake_paint_path_(path), fake_paint_(paint) {}
MockLayer::MockLayer(const SkPath& path, SkPaint paint)
: fake_paint_path_(path), fake_paint_(std::move(paint)) {}
bool MockLayer::IsReplacing(DiffContext* context, const Layer* layer) const {
// Similar to PictureLayer, only return true for identical mock layers;

View File

@@ -24,7 +24,7 @@ namespace testing {
// verify the data against expected values.
class MockLayer : public Layer {
public:
explicit MockLayer(SkPath path, SkPaint paint = SkPaint());
explicit MockLayer(const SkPath& path, SkPaint paint = SkPaint());
static std::shared_ptr<MockLayer> Make(SkPath path,
SkPaint paint = SkPaint()) {

View File

@@ -123,7 +123,7 @@ void ConcurrentMessageLoop::Terminate() {
tasks_condition_.notify_all();
}
void ConcurrentMessageLoop::PostTaskToAllWorkers(fml::closure task) {
void ConcurrentMessageLoop::PostTaskToAllWorkers(const fml::closure& task) {
if (!task) {
return;
}

View File

@@ -32,7 +32,7 @@ class ConcurrentMessageLoop
void Terminate();
void PostTaskToAllWorkers(fml::closure task);
void PostTaskToAllWorkers(const fml::closure& task);
private:
friend ConcurrentTaskRunner;

View File

@@ -57,8 +57,7 @@ class ICUContext {
std::initializer_list<FileMapping::Protection> protection = {
fml::FileMapping::Protection::kRead};
auto file_mapping =
std::make_unique<FileMapping>(fd, std::move(protection));
auto file_mapping = std::make_unique<FileMapping>(fd, protection);
if (file_mapping->GetSize() != 0) {
mapping_ = std::move(file_mapping);

View File

@@ -5,6 +5,7 @@
#define FML_USED_ON_EMBEDDER
#include <thread>
#include <utility>
#include "flutter/fml/message_loop_task_queues.h"
#include "flutter/fml/synchronization/count_down_latch.h"
@@ -19,7 +20,7 @@ class TestWakeable : public fml::Wakeable {
public:
using WakeUpCall = std::function<void(const fml::TimePoint)>;
explicit TestWakeable(WakeUpCall call) : wake_up_call_(call) {}
explicit TestWakeable(WakeUpCall call) : wake_up_call_(std::move(call)) {}
void WakeUp(fml::TimePoint time_point) override { wake_up_call_(time_point); }

View File

@@ -9,6 +9,7 @@
#include <algorithm>
#include <cstdlib>
#include <thread>
#include <utility>
#include "flutter/fml/synchronization/count_down_latch.h"
#include "flutter/fml/synchronization/waitable_event.h"
@@ -22,7 +23,7 @@ class TestWakeable : public fml::Wakeable {
public:
using WakeUpCall = std::function<void(const fml::TimePoint)>;
explicit TestWakeable(WakeUpCall call) : wake_up_call_(call) {}
explicit TestWakeable(WakeUpCall call) : wake_up_call_(std::move(call)) {}
void WakeUp(fml::TimePoint time_point) override { wake_up_call_(time_point); }

View File

@@ -6,6 +6,8 @@
#include "flutter/fml/raster_thread_merger.h"
#include <utility>
#include "flutter/fml/message_loop_impl.h"
namespace fml {
@@ -23,7 +25,7 @@ RasterThreadMerger::RasterThreadMerger(
fml::TaskQueueId gpu_queue_id)
: platform_queue_id_(platform_queue_id),
gpu_queue_id_(gpu_queue_id),
shared_merger_(shared_merger) {}
shared_merger_(std::move(shared_merger)) {}
void RasterThreadMerger::SetMergeUnmergeCallback(const fml::closure& callback) {
merge_unmerge_callback_ = callback;

View File

@@ -8,13 +8,13 @@ namespace fml {
SyncSwitch::Handlers& SyncSwitch::Handlers::SetIfTrue(
const std::function<void()>& handler) {
true_handler = std::move(handler);
true_handler = handler;
return *this;
}
SyncSwitch::Handlers& SyncSwitch::Handlers::SetIfFalse(
const std::function<void()>& handler) {
false_handler = std::move(handler);
false_handler = handler;
return *this;
}

View File

@@ -52,13 +52,13 @@ bool TaskRunner::RunsTasksOnCurrentThread() {
loop_queue_id);
}
void TaskRunner::RunNowOrPostTask(fml::RefPtr<fml::TaskRunner> runner,
void TaskRunner::RunNowOrPostTask(const fml::RefPtr<fml::TaskRunner>& runner,
const fml::closure& task) {
FML_DCHECK(runner);
if (runner->RunsTasksOnCurrentThread()) {
task();
} else {
runner->PostTask(std::move(task));
runner->PostTask(task);
}
}

View File

@@ -59,7 +59,7 @@ class TaskRunner : public fml::RefCountedThreadSafe<TaskRunner>,
/// Executes the \p task directly if the TaskRunner \p runner is the
/// TaskRunner associated with the current executing thread.
static void RunNowOrPostTask(fml::RefPtr<fml::TaskRunner> runner,
static void RunNowOrPostTask(const fml::RefPtr<fml::TaskRunner>& runner,
const fml::closure& task);
protected:

View File

@@ -107,7 +107,7 @@ bool Archive::UnarchiveInstance(const ArchiveDef& definition,
}
size_t Archive::UnarchiveInstances(const ArchiveDef& definition,
Archive::UnarchiveStep stepper,
const Archive::UnarchiveStep& stepper,
PrimaryKey primary_key) {
if (!IsValid()) {
return 0;

View File

@@ -65,7 +65,7 @@ class Archive {
Archivable& archivable);
size_t UnarchiveInstances(const ArchiveDef& definition,
UnarchiveStep stepper,
const UnarchiveStep& stepper,
PrimaryKey primary_key = std::nullopt);
FML_DISALLOW_COPY_AND_ASSIGN(Archive);

View File

@@ -94,11 +94,11 @@ std::shared_ptr<fml::Mapping> CreateMappingWithCopy(const uint8_t* contents,
std::memmove(allocation->GetBuffer(), contents, length);
return CreateMappingFromAllocation(std::move(allocation));
return CreateMappingFromAllocation(allocation);
}
std::shared_ptr<fml::Mapping> CreateMappingFromAllocation(
std::shared_ptr<Allocation> allocation) {
const std::shared_ptr<Allocation>& allocation) {
if (!allocation) {
return nullptr;
}

View File

@@ -44,7 +44,7 @@ std::shared_ptr<fml::Mapping> CreateMappingWithCopy(const uint8_t* contents,
size_t length);
std::shared_ptr<fml::Mapping> CreateMappingFromAllocation(
std::shared_ptr<Allocation> allocation);
const std::shared_ptr<Allocation>& allocation);
std::shared_ptr<fml::Mapping> CreateMappingWithString(
std::shared_ptr<const std::string> string);

View File

@@ -8,6 +8,7 @@
#include <filesystem>
#include <memory>
#include <sstream>
#include <utility>
#include "flutter/fml/paths.h"
#include "impeller/base/allocation.h"
@@ -21,7 +22,7 @@ namespace compiler {
const uint32_t kFragBindingBase = 128;
const size_t kNumUniformKinds =
int(shaderc_uniform_kind::shaderc_uniform_kind_buffer) + 1;
static_cast<int>(shaderc_uniform_kind::shaderc_uniform_kind_buffer) + 1;
static CompilerBackend CreateMSLCompiler(const spirv_cross::ParsedIR& ir,
const SourceOptions& source_options) {
@@ -236,7 +237,7 @@ void Compiler::SetBindingBase(shaderc::CompileOptions& compiler_opts) const {
}
Compiler::Compiler(const fml::Mapping& source_mapping,
SourceOptions source_options,
const SourceOptions& source_options,
Reflector::Options reflector_options)
: options_(source_options) {
if (source_mapping.GetMapping() == nullptr) {
@@ -465,7 +466,7 @@ const std::vector<std::string>& Compiler::GetIncludedFileNames() const {
}
static std::string JoinStrings(std::vector<std::string> items,
std::string separator) {
const std::string& separator) {
std::stringstream stream;
for (size_t i = 0, count = items.size(); i < count; i++) {
const auto is_last = (i == count - 1);
@@ -478,7 +479,7 @@ static std::string JoinStrings(std::vector<std::string> items,
return stream.str();
}
std::string Compiler::GetDependencyNames(std::string separator) const {
std::string Compiler::GetDependencyNames(const std::string& separator) const {
std::vector<std::string> dependencies = included_file_names_;
dependencies.push_back(options_.file_name);
return JoinStrings(dependencies, separator);

View File

@@ -24,7 +24,7 @@ namespace compiler {
class Compiler {
public:
Compiler(const fml::Mapping& source_mapping,
SourceOptions options,
const SourceOptions& options,
Reflector::Options reflector_options);
~Compiler();
@@ -55,7 +55,7 @@ class Compiler {
std::string GetSourcePrefix() const;
std::string GetDependencyNames(std::string separator) const;
std::string GetDependencyNames(const std::string& separator) const;
void SetBindingBase(shaderc::CompileOptions& compiler_opts) const;

View File

@@ -4,10 +4,12 @@
#include "impeller/entity/contents/filters/inputs/contents_filter_input.h"
#include <utility>
namespace impeller {
ContentsFilterInput::ContentsFilterInput(std::shared_ptr<Contents> contents)
: contents_(contents) {}
: contents_(std::move(contents)) {}
ContentsFilterInput::~ContentsFilterInput() = default;

View File

@@ -4,13 +4,15 @@
#include "impeller/entity/contents/filters/inputs/filter_contents_filter_input.h"
#include <utility>
#include "impeller/entity/contents/filters/filter_contents.h"
namespace impeller {
FilterContentsFilterInput::FilterContentsFilterInput(
std::shared_ptr<FilterContents> filter)
: filter_(filter) {}
: filter_(std::move(filter)) {}
FilterContentsFilterInput::~FilterContentsFilterInput() = default;

View File

@@ -5,6 +5,7 @@
#include "impeller/entity/contents/filters/inputs/filter_input.h"
#include <memory>
#include <utility>
#include "flutter/fml/logging.h"
#include "impeller/entity/contents/filters/filter_contents.h"
@@ -37,7 +38,7 @@ FilterInput::Ref FilterInput::Make(Variant input) {
FilterInput::Ref FilterInput::Make(std::shared_ptr<Texture> texture,
Matrix local_transform) {
return std::shared_ptr<TextureFilterInput>(
new TextureFilterInput(texture, local_transform));
new TextureFilterInput(std::move(texture), local_transform));
}
FilterInput::Vector FilterInput::Make(std::initializer_list<Variant> inputs) {

View File

@@ -4,11 +4,13 @@
#include "impeller/entity/contents/filters/inputs/texture_filter_input.h"
#include <utility>
namespace impeller {
TextureFilterInput::TextureFilterInput(std::shared_ptr<Texture> texture,
Matrix local_transform)
: texture_(texture), local_transform_(local_transform) {}
: texture_(std::move(texture)), local_transform_(local_transform) {}
TextureFilterInput::~TextureFilterInput() = default;

View File

@@ -4,6 +4,8 @@
#include "impeller/entity/inline_pass_context.h"
#include <utility>
#include "impeller/base/validation.h"
#include "impeller/renderer/command_buffer.h"
#include "impeller/renderer/formats.h"
@@ -12,9 +14,9 @@
namespace impeller {
InlinePassContext::InlinePassContext(std::shared_ptr<Context> context,
RenderTarget render_target,
const RenderTarget& render_target,
uint32_t pass_texture_reads)
: context_(context),
: context_(std::move(context)),
render_target_(render_target),
total_pass_reads_(pass_texture_reads) {}

View File

@@ -18,7 +18,7 @@ class InlinePassContext {
};
InlinePassContext(std::shared_ptr<Context> context,
RenderTarget render_target,
const RenderTarget& render_target,
uint32_t pass_texture_reads);
~InlinePassContext();

View File

@@ -75,10 +75,10 @@ void Path::SetContourClosed(bool is_closed) {
}
void Path::EnumerateComponents(
Applier<LinearPathComponent> linear_applier,
Applier<QuadraticPathComponent> quad_applier,
Applier<CubicPathComponent> cubic_applier,
Applier<ContourComponent> contour_applier) const {
const Applier<LinearPathComponent>& linear_applier,
const Applier<QuadraticPathComponent>& quad_applier,
const Applier<CubicPathComponent>& cubic_applier,
const Applier<ContourComponent>& contour_applier) const {
size_t currentIndex = 0;
for (const auto& component : components_) {
switch (component.type) {

View File

@@ -89,10 +89,11 @@ class Path {
template <class T>
using Applier = std::function<void(size_t index, const T& component)>;
void EnumerateComponents(Applier<LinearPathComponent> linear_applier,
Applier<QuadraticPathComponent> quad_applier,
Applier<CubicPathComponent> cubic_applier,
Applier<ContourComponent> contour_applier) const;
void EnumerateComponents(
const Applier<LinearPathComponent>& linear_applier,
const Applier<QuadraticPathComponent>& quad_applier,
const Applier<CubicPathComponent>& cubic_applier,
const Applier<ContourComponent>& contour_applier) const;
bool GetLinearComponentAtIndex(size_t index,
LinearPathComponent& linear) const;

View File

@@ -19,7 +19,7 @@ Path PathBuilder::CopyPath(FillType fill) const {
}
Path PathBuilder::TakePath(FillType fill) {
auto path = std::move(prototype_);
auto path = prototype_;
path.SetFillType(fill);
return path;
}

View File

@@ -161,7 +161,8 @@ void Playground::SetCursorPosition(Point pos) {
cursor_position_ = pos;
}
bool Playground::OpenPlaygroundHere(Renderer::RenderCallback render_callback) {
bool Playground::OpenPlaygroundHere(
const Renderer::RenderCallback& render_callback) {
if (!is_enabled()) {
return true;
}

View File

@@ -48,7 +48,7 @@ class Playground {
std::shared_ptr<Context> GetContext() const;
bool OpenPlaygroundHere(Renderer::RenderCallback render_callback);
bool OpenPlaygroundHere(const Renderer::RenderCallback& render_callback);
bool OpenPlaygroundHere(SinglePassCallback pass_callback);

View File

@@ -40,7 +40,7 @@ std::shared_ptr<DeviceBuffer> AllocatorGLES::OnCreateBuffer(
// |Allocator|
std::shared_ptr<Texture> AllocatorGLES::OnCreateTexture(
const TextureDescriptor& desc) {
return std::make_shared<TextureGLES>(reactor_, std::move(desc));
return std::make_shared<TextureGLES>(reactor_, desc);
}
// |Allocator|

View File

@@ -50,7 +50,7 @@ bool BufferBindingsGLES::RegisterVertexStageInput(
attrib.normalized = GL_FALSE;
attrib.offset = offset;
offset += (input.bit_width * input.vec_size) / 8;
vertex_attrib_arrays.emplace_back(std::move(attrib));
vertex_attrib_arrays.emplace_back(attrib);
}
for (auto& array : vertex_attrib_arrays) {
array.stride = offset;

View File

@@ -45,7 +45,7 @@ std::shared_ptr<RenderPass> CommandBufferGLES::OnCreateRenderPass(
return nullptr;
}
auto pass = std::shared_ptr<RenderPassGLES>(
new RenderPassGLES(context_, std::move(target), reactor_));
new RenderPassGLES(context_, target, reactor_));
if (!pass->IsValid()) {
return nullptr;
}

View File

@@ -12,14 +12,14 @@ namespace impeller {
std::shared_ptr<ContextGLES> ContextGLES::Create(
std::unique_ptr<ProcTableGLES> gl,
std::vector<std::shared_ptr<fml::Mapping>> shader_libraries) {
const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries) {
return std::shared_ptr<ContextGLES>(
new ContextGLES(std::move(gl), std::move(shader_libraries)));
new ContextGLES(std::move(gl), shader_libraries));
}
ContextGLES::ContextGLES(
std::unique_ptr<ProcTableGLES> gl,
std::vector<std::shared_ptr<fml::Mapping>> shader_libraries_mappings) {
ContextGLES::ContextGLES(std::unique_ptr<ProcTableGLES> gl,
const std::vector<std::shared_ptr<fml::Mapping>>&
shader_libraries_mappings) {
reactor_ = std::make_shared<ReactorGLES>(std::move(gl));
if (!reactor_->IsValid()) {
VALIDATION_LOG << "Could not create valid reactor.";
@@ -29,7 +29,7 @@ ContextGLES::ContextGLES(
// Create the shader library.
{
auto library = std::shared_ptr<ShaderLibraryGLES>(
new ShaderLibraryGLES(std::move(shader_libraries_mappings)));
new ShaderLibraryGLES(shader_libraries_mappings));
if (!library->IsValid()) {
VALIDATION_LOG << "Could not create valid shader library.";
return;
@@ -78,11 +78,11 @@ const ReactorGLES::Ref& ContextGLES::GetReactor() const {
}
std::optional<ReactorGLES::WorkerID> ContextGLES::AddReactorWorker(
std::shared_ptr<ReactorGLES::Worker> worker) {
const std::shared_ptr<ReactorGLES::Worker>& worker) {
if (!IsValid()) {
return std::nullopt;
}
return reactor_->AddWorker(std::move(worker));
return reactor_->AddWorker(worker);
}
bool ContextGLES::RemoveReactorWorker(ReactorGLES::WorkerID id) {

View File

@@ -21,7 +21,7 @@ class ContextGLES final : public Context,
public:
static std::shared_ptr<ContextGLES> Create(
std::unique_ptr<ProcTableGLES> gl,
std::vector<std::shared_ptr<fml::Mapping>> shader_libraries);
const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries);
// |Context|
~ContextGLES() override;
@@ -29,7 +29,7 @@ class ContextGLES final : public Context,
const ReactorGLES::Ref& GetReactor() const;
std::optional<ReactorGLES::WorkerID> AddReactorWorker(
std::shared_ptr<ReactorGLES::Worker> worker);
const std::shared_ptr<ReactorGLES::Worker>& worker);
bool RemoveReactorWorker(ReactorGLES::WorkerID id);
@@ -42,8 +42,9 @@ class ContextGLES final : public Context,
std::shared_ptr<AllocatorGLES> resource_allocator_;
bool is_valid_ = false;
ContextGLES(std::unique_ptr<ProcTableGLES> gl,
std::vector<std::shared_ptr<fml::Mapping>> shader_libraries);
ContextGLES(
std::unique_ptr<ProcTableGLES> gl,
const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries);
// |Context|
bool IsValid() const override;

View File

@@ -62,7 +62,7 @@ static std::optional<Version> DetermineVersion(std::string version) {
std::getline(istream, version_component, '.');) {
version_components.push_back(std::stoul(version_component));
}
return Version::FromVector(std::move(version_components));
return Version::FromVector(version_components);
}
DescriptionGLES::DescriptionGLES(const ProcTableGLES& gl)

View File

@@ -17,7 +17,7 @@ namespace impeller {
DeviceBufferGLES::DeviceBufferGLES(DeviceBufferDescriptor desc,
ReactorGLES::Ref reactor,
std::shared_ptr<Allocation> backing_store)
: DeviceBuffer(std::move(desc)),
: DeviceBuffer(desc),
reactor_(std::move(reactor)),
handle_(reactor_ ? reactor_->CreateHandle(HandleType::kBuffer)
: HandleGLES::DeadHandle()),

View File

@@ -8,8 +8,8 @@ namespace impeller {
PipelineGLES::PipelineGLES(ReactorGLES::Ref reactor,
std::weak_ptr<PipelineLibrary> library,
PipelineDescriptor desc)
: Pipeline(std::move(library), std::move(desc)),
const PipelineDescriptor& desc)
: Pipeline(std::move(library), desc),
reactor_(std::move(reactor)),
handle_(reactor_ ? reactor_->CreateHandle(HandleType::kProgram)
: HandleGLES::DeadHandle()),
@@ -22,7 +22,7 @@ PipelineGLES::PipelineGLES(ReactorGLES::Ref reactor,
// |Pipeline|
PipelineGLES::~PipelineGLES() {
if (!handle_.IsDead()) {
reactor_->CollectHandle(std::move(handle_));
reactor_->CollectHandle(handle_);
}
}

View File

@@ -46,7 +46,7 @@ class PipelineGLES final
PipelineGLES(ReactorGLES::Ref reactor,
std::weak_ptr<PipelineLibrary> library,
PipelineDescriptor desc);
const PipelineDescriptor& desc);
FML_DISALLOW_COPY_AND_ASSIGN(PipelineGLES);
};

View File

@@ -70,7 +70,7 @@ static void LogShaderCompilationFailure(const ProcTableGLES& gl,
static bool LinkProgram(
const ReactorGLES& reactor,
std::shared_ptr<PipelineGLES> pipeline,
const std::shared_ptr<PipelineGLES>& pipeline,
const std::shared_ptr<const ShaderFunction>& vert_function,
const std::shared_ptr<const ShaderFunction>& frag_function) {
TRACE_EVENT0("impeller", __FUNCTION__);
@@ -217,10 +217,10 @@ PipelineFuture<PipelineDescriptor> PipelineLibraryGLES::GetPipeline(
VALIDATION_LOG << "Could not obtain program handle.";
return;
}
const auto link_result = LinkProgram(reactor, //
pipeline, //
std::move(vert_function), //
std::move(frag_function) //
const auto link_result = LinkProgram(reactor, //
pipeline, //
vert_function, //
frag_function //
);
if (!link_result) {
promise->set_value(nullptr);

View File

@@ -32,7 +32,8 @@ const char* GLErrorToString(GLenum value) {
return "Unknown.";
}
ProcTableGLES::Resolver WrappedResolver(ProcTableGLES::Resolver resolver) {
ProcTableGLES::Resolver WrappedResolver(
const ProcTableGLES::Resolver& resolver) {
return [resolver](const char* function_name) -> void* {
auto resolved = resolver(function_name);
if (resolved) {

View File

@@ -141,7 +141,7 @@ HandleGLES ReactorGLES::CreateHandle(HandleType type) {
auto gl_handle = CanReactOnCurrentThread()
? CreateGLHandle(GetProcTable(), type)
: std::nullopt;
handles_[new_handle] = LiveHandle{std::move(gl_handle)};
handles_[new_handle] = LiveHandle{gl_handle};
return new_handle;
}
@@ -214,7 +214,7 @@ bool ReactorGLES::ConsolidateHandles() {
VALIDATION_LOG << "Could not create GL handle.";
return false;
}
handle.second.name = std::move(gl_handle);
handle.second.name = gl_handle;
}
// Set pending debug labels.
if (handle.second.pending_debug_label.has_value()) {

View File

@@ -17,9 +17,9 @@
namespace impeller {
RenderPassGLES::RenderPassGLES(std::weak_ptr<const Context> context,
RenderTarget target,
const RenderTarget& target,
ReactorGLES::Ref reactor)
: RenderPass(std::move(context), std::move(target)),
: RenderPass(std::move(context), target),
reactor_(std::move(reactor)),
is_valid_(reactor_ && reactor_->IsValid()) {}

View File

@@ -23,7 +23,7 @@ class RenderPassGLES final : public RenderPass {
bool is_valid_ = false;
RenderPassGLES(std::weak_ptr<const Context> context,
RenderTarget target,
const RenderTarget& target,
ReactorGLES::Ref reactor);
// |RenderPass|

View File

@@ -55,7 +55,7 @@ static std::string GLESShaderNameToShaderKeyName(const std::string& name,
}
ShaderLibraryGLES::ShaderLibraryGLES(
std::vector<std::shared_ptr<fml::Mapping>> shader_libraries) {
const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries) {
ShaderFunctionMap functions;
auto iterator = [&functions, library_id = library_id_](auto type, //
const auto& name, //

View File

@@ -31,7 +31,7 @@ class ShaderLibraryGLES final : public ShaderLibrary {
bool is_valid_ = false;
ShaderLibraryGLES(
std::vector<std::shared_ptr<fml::Mapping>> shader_libraries);
const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries);
// |ShaderLibrary|
std::shared_ptr<const ShaderFunction> GetFunction(std::string_view name,

View File

@@ -11,11 +11,12 @@
namespace impeller {
std::unique_ptr<Surface> SurfaceGLES::WrapFBO(std::shared_ptr<Context> context,
SwapCallback swap_callback,
GLuint fbo,
PixelFormat color_format,
ISize fbo_size) {
std::unique_ptr<Surface> SurfaceGLES::WrapFBO(
const std::shared_ptr<Context>& context,
SwapCallback swap_callback,
GLuint fbo,
PixelFormat color_format,
ISize fbo_size) {
TRACE_EVENT0("impeller", "SurfaceGLES::WrapOnScreenFBO");
if (context == nullptr || !context->IsValid() || !swap_callback) {
@@ -34,8 +35,7 @@ std::unique_ptr<Surface> SurfaceGLES::WrapFBO(std::shared_ptr<Context> context,
ColorAttachment color0;
color0.texture = std::make_shared<TextureGLES>(
gl_context.GetReactor(), std::move(color0_tex),
TextureGLES::IsWrapped::kWrapped);
gl_context.GetReactor(), color0_tex, TextureGLES::IsWrapped::kWrapped);
color0.clear_color = Color::DarkSlateGray();
color0.load_action = LoadAction::kClear;
color0.store_action = StoreAction::kStore;
@@ -51,8 +51,7 @@ std::unique_ptr<Surface> SurfaceGLES::WrapFBO(std::shared_ptr<Context> context,
StencilAttachment stencil0;
stencil0.clear_stencil = 0;
stencil0.texture = std::make_shared<TextureGLES>(
gl_context.GetReactor(), std::move(stencil0_tex),
TextureGLES::IsWrapped::kWrapped);
gl_context.GetReactor(), stencil0_tex, TextureGLES::IsWrapped::kWrapped);
stencil0.load_action = LoadAction::kClear;
stencil0.store_action = StoreAction::kDontCare;
@@ -62,12 +61,12 @@ std::unique_ptr<Surface> SurfaceGLES::WrapFBO(std::shared_ptr<Context> context,
render_target_desc.SetStencilAttachment(stencil0);
return std::unique_ptr<SurfaceGLES>(
new SurfaceGLES(std::move(swap_callback), std::move(render_target_desc)));
new SurfaceGLES(std::move(swap_callback), render_target_desc));
}
SurfaceGLES::SurfaceGLES(SwapCallback swap_callback, RenderTarget target_desc)
: Surface(std::move(target_desc)),
swap_callback_(std::move(swap_callback)) {}
SurfaceGLES::SurfaceGLES(SwapCallback swap_callback,
const RenderTarget& target_desc)
: Surface(target_desc), swap_callback_(std::move(swap_callback)) {}
// |Surface|
SurfaceGLES::~SurfaceGLES() = default;

View File

@@ -18,11 +18,12 @@ class SurfaceGLES final : public Surface {
public:
using SwapCallback = std::function<bool(void)>;
static std::unique_ptr<Surface> WrapFBO(std::shared_ptr<Context> context,
SwapCallback swap_callback,
GLuint fbo,
PixelFormat color_format,
ISize fbo_size);
static std::unique_ptr<Surface> WrapFBO(
const std::shared_ptr<Context>& context,
SwapCallback swap_callback,
GLuint fbo,
PixelFormat color_format,
ISize fbo_size);
// |Surface|
~SurfaceGLES() override;
@@ -30,7 +31,7 @@ class SurfaceGLES final : public Surface {
private:
SwapCallback swap_callback_;
SurfaceGLES(SwapCallback swap_callback, RenderTarget target_desc);
SurfaceGLES(SwapCallback swap_callback, const RenderTarget& target_desc);
// |Surface|
bool Present() const override;

View File

@@ -5,6 +5,7 @@
#include "impeller/renderer/backend/gles/texture_gles.h"
#include <optional>
#include <utility>
#include "flutter/fml/mapping.h"
#include "flutter/fml/trace_event.h"
@@ -38,18 +39,18 @@ HandleType ToHandleType(TextureGLES::Type type) {
}
TextureGLES::TextureGLES(ReactorGLES::Ref reactor, TextureDescriptor desc)
: TextureGLES(std::move(reactor), std::move(desc), false) {}
: TextureGLES(std::move(reactor), desc, false) {}
TextureGLES::TextureGLES(ReactorGLES::Ref reactor,
TextureDescriptor desc,
enum IsWrapped wrapped)
: TextureGLES(std::move(reactor), std::move(desc), true) {}
: TextureGLES(std::move(reactor), desc, true) {}
TextureGLES::TextureGLES(std::shared_ptr<ReactorGLES> reactor,
TextureDescriptor desc,
bool is_wrapped)
: Texture(std::move(desc)),
reactor_(reactor),
: Texture(desc),
reactor_(std::move(reactor)),
type_(GetTextureTypeFromDescriptor(GetTextureDescriptor())),
handle_(reactor_->CreateHandle(ToHandleType(type_))),
is_wrapped_(is_wrapped) {
@@ -72,7 +73,7 @@ TextureGLES::TextureGLES(std::shared_ptr<ReactorGLES> reactor,
// |Texture|
TextureGLES::~TextureGLES() {
reactor_->CollectHandle(std::move(handle_));
reactor_->CollectHandle(handle_);
}
// |Texture|

View File

@@ -21,7 +21,7 @@ class CommandBufferMTL final : public CommandBuffer {
id<MTLCommandBuffer> buffer_ = nullptr;
CommandBufferMTL(const std::weak_ptr<const Context> context,
CommandBufferMTL(const std::weak_ptr<const Context>& context,
id<MTLCommandQueue> queue);
// |CommandBuffer|

View File

@@ -121,9 +121,9 @@ static id<MTLCommandBuffer> CreateCommandBuffer(id<MTLCommandQueue> queue) {
return [queue commandBuffer];
}
CommandBufferMTL::CommandBufferMTL(const std::weak_ptr<const Context> context,
CommandBufferMTL::CommandBufferMTL(const std::weak_ptr<const Context>& context,
id<MTLCommandQueue> queue)
: CommandBuffer(std::move(context)), buffer_(CreateCommandBuffer(queue)) {}
: CommandBuffer(context), buffer_(CreateCommandBuffer(queue)) {}
CommandBufferMTL::~CommandBufferMTL() = default;
@@ -176,7 +176,7 @@ std::shared_ptr<RenderPass> CommandBufferMTL::OnCreateRenderPass(
}
auto pass = std::shared_ptr<RenderPassMTL>(
new RenderPassMTL(context_, std::move(target), buffer_));
new RenderPassMTL(context_, target, buffer_));
if (!pass->IsValid()) {
return nullptr;
}

View File

@@ -14,9 +14,7 @@ namespace impeller {
DeviceBufferMTL::DeviceBufferMTL(DeviceBufferDescriptor desc,
id<MTLBuffer> buffer,
MTLStorageMode storage_mode)
: DeviceBuffer(std::move(desc)),
buffer_(buffer),
storage_mode_(storage_mode) {}
: DeviceBuffer(desc), buffer_(buffer), storage_mode_(storage_mode) {}
DeviceBufferMTL::~DeviceBufferMTL() = default;

View File

@@ -31,7 +31,7 @@ class PipelineMTL final
bool is_valid_ = false;
PipelineMTL(std::weak_ptr<PipelineLibrary> library,
PipelineDescriptor desc,
const PipelineDescriptor& desc,
id<MTLRenderPipelineState> state,
id<MTLDepthStencilState> depth_stencil_state);

View File

@@ -7,10 +7,10 @@
namespace impeller {
PipelineMTL::PipelineMTL(std::weak_ptr<PipelineLibrary> library,
PipelineDescriptor desc,
const PipelineDescriptor& desc,
id<MTLRenderPipelineState> state,
id<MTLDepthStencilState> depth_stencil_state)
: Pipeline(std::move(library), std::move(desc)),
: Pipeline(std::move(library), desc),
pipeline_state_(state),
depth_stencil_state_(depth_stencil_state) {
if (!pipeline_state_) {

View File

@@ -26,7 +26,7 @@ class RenderPassMTL final : public RenderPass {
bool is_valid_ = false;
RenderPassMTL(std::weak_ptr<const Context> context,
RenderTarget target,
const RenderTarget& target,
id<MTLCommandBuffer> buffer);
// |RenderPass|

View File

@@ -131,9 +131,9 @@ static MTLRenderPassDescriptor* ToMTLRenderPassDescriptor(
}
RenderPassMTL::RenderPassMTL(std::weak_ptr<const Context> context,
RenderTarget target,
const RenderTarget& target,
id<MTLCommandBuffer> buffer)
: RenderPass(std::move(context), std::move(target)),
: RenderPass(std::move(context), target),
buffer_(buffer),
desc_(ToMTLRenderPassDescriptor(GetRenderTarget())) {
if (!buffer_ || !desc_ || !render_target_.IsValid()) {

View File

@@ -10,7 +10,7 @@ ShaderFunctionMTL::ShaderFunctionMTL(UniqueID parent_library_id,
id<MTLFunction> function,
std::string name,
ShaderStage stage)
: ShaderFunction(std::move(parent_library_id), std::move(name), stage),
: ShaderFunction(parent_library_id, std::move(name), stage),
function_(function) {}
ShaderFunctionMTL::~ShaderFunctionMTL() = default;

View File

@@ -33,7 +33,7 @@ class SurfaceMTL final : public Surface {
/// @return A pointer to the wrapped surface or null.
///
static std::unique_ptr<Surface> WrapCurrentMetalLayerDrawable(
std::shared_ptr<Context> context,
const std::shared_ptr<Context>& context,
CAMetalLayer* layer);
#pragma GCC diagnostic pop
@@ -43,7 +43,7 @@ class SurfaceMTL final : public Surface {
private:
id<MTLDrawable> drawable_ = nil;
SurfaceMTL(RenderTarget target, id<MTLDrawable> drawable);
SurfaceMTL(const RenderTarget& target, id<MTLDrawable> drawable);
// |Surface|
bool Present() const override;

View File

@@ -16,7 +16,7 @@ namespace impeller {
#pragma GCC diagnostic ignored "-Wunguarded-availability-new"
std::unique_ptr<Surface> SurfaceMTL::WrapCurrentMetalLayerDrawable(
std::shared_ptr<Context> context,
const std::shared_ptr<Context>& context,
CAMetalLayer* layer) {
TRACE_EVENT0("impeller", "SurfaceMTL::WrapCurrentMetalLayerDrawable");
@@ -106,11 +106,11 @@ std::unique_ptr<Surface> SurfaceMTL::WrapCurrentMetalLayerDrawable(
// The constructor is private. So make_unique may not be used.
return std::unique_ptr<SurfaceMTL>(
new SurfaceMTL(std::move(render_target_desc), current_drawable));
new SurfaceMTL(render_target_desc, current_drawable));
}
SurfaceMTL::SurfaceMTL(RenderTarget target, id<MTLDrawable> drawable)
: Surface(std::move(target)), drawable_(drawable) {}
SurfaceMTL::SurfaceMTL(const RenderTarget& target, id<MTLDrawable> drawable)
: Surface(target), drawable_(drawable) {}
// |Surface|
SurfaceMTL::~SurfaceMTL() = default;

View File

@@ -9,7 +9,7 @@
namespace impeller {
TextureMTL::TextureMTL(TextureDescriptor p_desc, id<MTLTexture> texture)
: Texture(std::move(p_desc)), texture_(texture) {
: Texture(p_desc), texture_(texture) {
const auto& desc = GetTextureDescriptor();
if (!desc.IsValid() || !texture_) {

View File

@@ -4,6 +4,8 @@
#include "impeller/renderer/command.h"
#include <utility>
#include "impeller/base/validation.h"
#include "impeller/renderer/formats.h"
#include "impeller/renderer/vertex_descriptor.h"
@@ -36,7 +38,7 @@ BufferView Command::GetVertexBuffer() const {
bool Command::BindResource(ShaderStage stage,
const ShaderUniformSlot& slot,
const ShaderMetadata& metadata,
BufferView view) {
const BufferView& view) {
if (!view) {
return false;
}
@@ -64,7 +66,7 @@ bool Command::BindResource(ShaderStage stage,
bool Command::BindResource(ShaderStage stage,
const SampledImageSlot& slot,
const ShaderMetadata& metadata,
std::shared_ptr<const Texture> texture) {
const std::shared_ptr<const Texture>& texture) {
if (!texture || !texture->IsValid()) {
return false;
}
@@ -94,7 +96,7 @@ bool Command::BindResource(ShaderStage stage,
bool Command::BindResource(ShaderStage stage,
const SampledImageSlot& slot,
const ShaderMetadata& metadata,
std::shared_ptr<const Sampler> sampler) {
const std::shared_ptr<const Sampler>& sampler) {
if (!sampler || !sampler->IsValid()) {
return false;
}
@@ -124,8 +126,8 @@ bool Command::BindResource(ShaderStage stage,
bool Command::BindResource(ShaderStage stage,
const SampledImageSlot& slot,
const ShaderMetadata& metadata,
std::shared_ptr<const Texture> texture,
std::shared_ptr<const Sampler> sampler) {
const std::shared_ptr<const Texture>& texture,
const std::shared_ptr<const Sampler>& sampler) {
return BindResource(stage, slot, metadata, texture) &&
BindResource(stage, slot, metadata, sampler);
}

View File

@@ -154,23 +154,23 @@ struct Command {
bool BindResource(ShaderStage stage,
const ShaderUniformSlot& slot,
const ShaderMetadata& metadata,
BufferView view);
const BufferView& view);
bool BindResource(ShaderStage stage,
const SampledImageSlot& slot,
const ShaderMetadata& metadata,
std::shared_ptr<const Texture> texture);
const std::shared_ptr<const Texture>& texture);
bool BindResource(ShaderStage stage,
const SampledImageSlot& slot,
const ShaderMetadata& metadata,
std::shared_ptr<const Sampler> sampler);
const std::shared_ptr<const Sampler>& sampler);
bool BindResource(ShaderStage stage,
const SampledImageSlot& slot,
const ShaderMetadata& metadata,
std::shared_ptr<const Texture> texture,
std::shared_ptr<const Sampler> sampler);
const std::shared_ptr<const Texture>& texture,
const std::shared_ptr<const Sampler>& sampler);
BufferView GetVertexBuffer() const;

View File

@@ -16,7 +16,7 @@ CommandBuffer::CommandBuffer(std::weak_ptr<const Context> context)
CommandBuffer::~CommandBuffer() = default;
bool CommandBuffer::SubmitCommands(CompletionCallback callback) {
bool CommandBuffer::SubmitCommands(const CompletionCallback& callback) {
TRACE_EVENT0("impeller", "CommandBuffer::SubmitCommands");
if (!IsValid()) {
// Already committed or was never valid. Either way, this is caller error.
@@ -33,8 +33,8 @@ bool CommandBuffer::SubmitCommands() {
}
std::shared_ptr<RenderPass> CommandBuffer::CreateRenderPass(
RenderTarget render_target) {
auto pass = OnCreateRenderPass(std::move(render_target));
const RenderTarget& render_target) {
auto pass = OnCreateRenderPass(render_target);
if (pass && pass->IsValid()) {
pass->SetLabel("RenderPass");
return pass;

View File

@@ -61,7 +61,7 @@ class CommandBuffer {
///
/// @param[in] callback The completion callback.
///
[[nodiscard]] bool SubmitCommands(CompletionCallback callback);
[[nodiscard]] bool SubmitCommands(const CompletionCallback& callback);
[[nodiscard]] bool SubmitCommands();
@@ -73,7 +73,8 @@ class CommandBuffer {
///
/// @return A valid render pass or null.
///
std::shared_ptr<RenderPass> CreateRenderPass(RenderTarget render_target);
std::shared_ptr<RenderPass> CreateRenderPass(
const RenderTarget& render_target);
//----------------------------------------------------------------------------
/// @brief Create a blit pass to record blit commands into.

View File

@@ -6,8 +6,7 @@
namespace impeller {
DeviceBuffer::DeviceBuffer(DeviceBufferDescriptor desc)
: desc_(std::move(desc)) {}
DeviceBuffer::DeviceBuffer(DeviceBufferDescriptor desc) : desc_(desc) {}
DeviceBuffer::~DeviceBuffer() = default;

View File

@@ -94,7 +94,7 @@ PipelineDescriptor& PipelineDescriptor::SetVertexDescriptor(
PipelineDescriptor& PipelineDescriptor::SetColorAttachmentDescriptor(
size_t index,
ColorAttachmentDescriptor desc) {
color_attachment_descriptors_[index] = std::move(desc);
color_attachment_descriptors_[index] = desc;
return *this;
}

View File

@@ -13,7 +13,7 @@ PipelineLibrary::~PipelineLibrary() = default;
PipelineFuture<PipelineDescriptor> PipelineLibrary::GetPipeline(
std::optional<PipelineDescriptor> descriptor) {
if (descriptor.has_value()) {
return GetPipeline(std::move(descriptor.value()));
return GetPipeline(descriptor.value());
}
auto promise = std::make_shared<
std::promise<std::shared_ptr<Pipeline<PipelineDescriptor>>>>();
@@ -24,7 +24,7 @@ PipelineFuture<PipelineDescriptor> PipelineLibrary::GetPipeline(
PipelineFuture<ComputePipelineDescriptor> PipelineLibrary::GetPipeline(
std::optional<ComputePipelineDescriptor> descriptor) {
if (descriptor.has_value()) {
return GetPipeline(std::move(descriptor.value()));
return GetPipeline(descriptor.value());
}
auto promise = std::make_shared<
std::promise<std::shared_ptr<Pipeline<ComputePipelineDescriptor>>>>();

View File

@@ -7,9 +7,9 @@
namespace impeller {
RenderPass::RenderPass(std::weak_ptr<const Context> context,
RenderTarget target)
const RenderTarget& target)
: context_(std::move(context)),
render_target_(std::move(target)),
render_target_(target),
transients_buffer_(HostBuffer::Create()) {}
RenderPass::~RenderPass() = default;

View File

@@ -62,7 +62,7 @@ class RenderPass {
std::shared_ptr<HostBuffer> transients_buffer_;
std::vector<Command> commands_;
RenderPass(std::weak_ptr<const Context> context, RenderTarget target);
RenderPass(std::weak_ptr<const Context> context, const RenderTarget& target);
virtual void OnSetLabel(std::string label) = 0;

View File

@@ -82,7 +82,7 @@ bool RenderTarget::IsValid() const {
}
void RenderTarget::IterateAllAttachments(
std::function<bool(const Attachment& attachment)> iterator) const {
const std::function<bool(const Attachment& attachment)>& iterator) const {
for (const auto& color : colors_) {
if (!iterator(color.second)) {
return;
@@ -140,8 +140,9 @@ std::shared_ptr<Texture> RenderTarget::GetRenderTargetTexture() const {
: found->second.texture;
}
RenderTarget& RenderTarget::SetColorAttachment(ColorAttachment attachment,
size_t index) {
RenderTarget& RenderTarget::SetColorAttachment(
const ColorAttachment& attachment,
size_t index) {
if (attachment.IsValid()) {
colors_[index] = attachment;
}

View File

@@ -35,7 +35,8 @@ class RenderTarget {
std::optional<ISize> GetColorAttachmentSize(size_t index) const;
RenderTarget& SetColorAttachment(ColorAttachment attachment, size_t index);
RenderTarget& SetColorAttachment(const ColorAttachment& attachment,
size_t index);
RenderTarget& SetDepthAttachment(DepthAttachment attachment);
@@ -53,7 +54,7 @@ class RenderTarget {
std::optional<StencilAttachment> stencil_;
void IterateAllAttachments(
std::function<bool(const Attachment& attachment)> iterator) const;
const std::function<bool(const Attachment& attachment)>& iterator) const;
};
} // namespace impeller

View File

@@ -33,7 +33,7 @@ bool Renderer::IsValid() const {
}
bool Renderer::Render(std::unique_ptr<Surface> surface,
RenderCallback render_callback) const {
const RenderCallback& render_callback) const {
TRACE_EVENT0("impeller", "Renderer::Render");
if (!IsValid()) {
return false;

View File

@@ -31,7 +31,8 @@ class Renderer {
bool IsValid() const;
bool Render(std::unique_ptr<Surface> surface, RenderCallback callback) const;
bool Render(std::unique_ptr<Surface> surface,
const RenderCallback& callback) const;
std::shared_ptr<Context> GetContext() const;

View File

@@ -10,7 +10,7 @@ namespace impeller {
Surface::Surface() : Surface(RenderTarget{}) {}
Surface::Surface(RenderTarget target_desc) : desc_(std::move(target_desc)) {
Surface::Surface(const RenderTarget& target_desc) : desc_(target_desc) {
if (auto size = desc_.GetColorAttachmentSize(0u); size.has_value()) {
size_ = size.value();
} else {

View File

@@ -18,7 +18,7 @@ class Surface {
public:
Surface();
explicit Surface(RenderTarget target_desc);
explicit Surface(const RenderTarget& target_desc);
virtual ~Surface();

View File

@@ -8,7 +8,7 @@
namespace impeller {
Texture::Texture(TextureDescriptor desc) : desc_(std::move(desc)) {}
Texture::Texture(TextureDescriptor desc) : desc_(desc) {}
Texture::~Texture() = default;

View File

@@ -34,9 +34,10 @@ static void DestroyTessellator(TESStesselator* tessellator) {
}
}
Tessellator::Result Tessellator::Tessellate(FillType fill_type,
const Path::Polyline& polyline,
VertexCallback callback) const {
Tessellator::Result Tessellator::Tessellate(
FillType fill_type,
const Path::Polyline& polyline,
const VertexCallback& callback) const {
if (!callback) {
return Result::kInputError;
}

Some files were not shown because too many files have changed in this diff Show More