Removes ReactorGLES::Ref (flutter/engine#56981)

This typedef really wasn't making the codebase any easier to work with.  We don't do this for other std::shared_ptr's

test-exempt: just removes typedef

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
gaaclarke 2024-12-05 13:06:11 -08:00 committed by GitHub
parent 2e80dbea2c
commit 72d1c2fea6
21 changed files with 56 additions and 51 deletions

View File

@ -13,7 +13,7 @@
namespace impeller { namespace impeller {
AllocatorGLES::AllocatorGLES(ReactorGLES::Ref reactor) AllocatorGLES::AllocatorGLES(std::shared_ptr<ReactorGLES> reactor)
: reactor_(std::move(reactor)), is_valid_(true) {} : reactor_(std::move(reactor)), is_valid_(true) {}
// |Allocator| // |Allocator|

View File

@ -18,10 +18,10 @@ class AllocatorGLES final : public Allocator {
private: private:
friend class ContextGLES; friend class ContextGLES;
ReactorGLES::Ref reactor_; std::shared_ptr<ReactorGLES> reactor_;
bool is_valid_ = false; bool is_valid_ = false;
explicit AllocatorGLES(ReactorGLES::Ref reactor); explicit AllocatorGLES(std::shared_ptr<ReactorGLES> reactor);
// |Allocator| // |Allocator|
bool IsValid() const; bool IsValid() const;

View File

@ -14,7 +14,7 @@
namespace impeller { namespace impeller {
BlitPassGLES::BlitPassGLES(ReactorGLES::Ref reactor) BlitPassGLES::BlitPassGLES(std::shared_ptr<ReactorGLES> reactor)
: reactor_(std::move(reactor)), : reactor_(std::move(reactor)),
is_valid_(reactor_ && reactor_->IsValid()) {} is_valid_(reactor_ && reactor_->IsValid()) {}

View File

@ -25,11 +25,11 @@ class BlitPassGLES final : public BlitPass,
friend class CommandBufferGLES; friend class CommandBufferGLES;
std::vector<std::unique_ptr<BlitEncodeGLES>> commands_; std::vector<std::unique_ptr<BlitEncodeGLES>> commands_;
ReactorGLES::Ref reactor_; std::shared_ptr<ReactorGLES> reactor_;
std::string label_; std::string label_;
bool is_valid_ = false; bool is_valid_ = false;
explicit BlitPassGLES(ReactorGLES::Ref reactor); explicit BlitPassGLES(std::shared_ptr<ReactorGLES> reactor);
// |BlitPass| // |BlitPass|
bool IsValid() const override; bool IsValid() const override;

View File

@ -11,7 +11,7 @@
namespace impeller { namespace impeller {
CommandBufferGLES::CommandBufferGLES(std::weak_ptr<const Context> context, CommandBufferGLES::CommandBufferGLES(std::weak_ptr<const Context> context,
ReactorGLES::Ref reactor) std::shared_ptr<ReactorGLES> reactor)
: CommandBuffer(std::move(context)), : CommandBuffer(std::move(context)),
reactor_(std::move(reactor)), reactor_(std::move(reactor)),
is_valid_(reactor_ && reactor_->IsValid()) {} is_valid_(reactor_ && reactor_->IsValid()) {}

View File

@ -19,11 +19,11 @@ class CommandBufferGLES final : public CommandBuffer {
private: private:
friend class ContextGLES; friend class ContextGLES;
ReactorGLES::Ref reactor_; std::shared_ptr<ReactorGLES> reactor_;
bool is_valid_ = false; bool is_valid_ = false;
CommandBufferGLES(std::weak_ptr<const Context> context, CommandBufferGLES(std::weak_ptr<const Context> context,
ReactorGLES::Ref reactor); std::shared_ptr<ReactorGLES> reactor);
// |CommandBuffer| // |CommandBuffer|
void SetLabel(std::string_view label) const override; void SetLabel(std::string_view label) const override;

View File

@ -83,7 +83,7 @@ Context::BackendType ContextGLES::GetBackendType() const {
return Context::BackendType::kOpenGLES; return Context::BackendType::kOpenGLES;
} }
const ReactorGLES::Ref& ContextGLES::GetReactor() const { const std::shared_ptr<ReactorGLES>& ContextGLES::GetReactor() const {
return reactor_; return reactor_;
} }

View File

@ -35,7 +35,7 @@ class ContextGLES final : public Context,
// |Context| // |Context|
BackendType GetBackendType() const override; BackendType GetBackendType() const override;
const ReactorGLES::Ref& GetReactor() const; const std::shared_ptr<ReactorGLES>& GetReactor() const;
std::optional<ReactorGLES::WorkerID> AddReactorWorker( std::optional<ReactorGLES::WorkerID> AddReactorWorker(
const std::shared_ptr<ReactorGLES::Worker>& worker); const std::shared_ptr<ReactorGLES::Worker>& worker);
@ -45,7 +45,7 @@ class ContextGLES final : public Context,
std::shared_ptr<GPUTracerGLES> GetGPUTracer() const { return gpu_tracer_; } std::shared_ptr<GPUTracerGLES> GetGPUTracer() const { return gpu_tracer_; }
private: private:
ReactorGLES::Ref reactor_; std::shared_ptr<ReactorGLES> reactor_;
std::shared_ptr<ShaderLibraryGLES> shader_library_; std::shared_ptr<ShaderLibraryGLES> shader_library_;
std::shared_ptr<PipelineLibraryGLES> pipeline_library_; std::shared_ptr<PipelineLibraryGLES> pipeline_library_;
std::shared_ptr<SamplerLibraryGLES> sampler_library_; std::shared_ptr<SamplerLibraryGLES> sampler_library_;

View File

@ -13,7 +13,7 @@
namespace impeller { namespace impeller {
DeviceBufferGLES::DeviceBufferGLES(DeviceBufferDescriptor desc, DeviceBufferGLES::DeviceBufferGLES(DeviceBufferDescriptor desc,
ReactorGLES::Ref reactor, std::shared_ptr<ReactorGLES> reactor,
std::shared_ptr<Allocation> backing_store) std::shared_ptr<Allocation> backing_store)
: DeviceBuffer(desc), : DeviceBuffer(desc),
reactor_(std::move(reactor)), reactor_(std::move(reactor)),

View File

@ -20,7 +20,7 @@ class DeviceBufferGLES final
public BackendCast<DeviceBufferGLES, DeviceBuffer> { public BackendCast<DeviceBufferGLES, DeviceBuffer> {
public: public:
DeviceBufferGLES(DeviceBufferDescriptor desc, DeviceBufferGLES(DeviceBufferDescriptor desc,
ReactorGLES::Ref reactor, std::shared_ptr<ReactorGLES> reactor,
std::shared_ptr<Allocation> backing_store); std::shared_ptr<Allocation> backing_store);
// |DeviceBuffer| // |DeviceBuffer|
@ -44,7 +44,7 @@ class DeviceBufferGLES final
std::optional<GLuint> GetHandle() const; std::optional<GLuint> GetHandle() const;
private: private:
ReactorGLES::Ref reactor_; std::shared_ptr<ReactorGLES> reactor_;
HandleGLES handle_; HandleGLES handle_;
mutable std::shared_ptr<Allocation> backing_store_; mutable std::shared_ptr<Allocation> backing_store_;
mutable std::optional<Range> dirty_range_ = std::nullopt; mutable std::optional<Range> dirty_range_ = std::nullopt;

View File

@ -6,7 +6,7 @@
namespace impeller { namespace impeller {
PipelineGLES::PipelineGLES(ReactorGLES::Ref reactor, PipelineGLES::PipelineGLES(std::shared_ptr<ReactorGLES> reactor,
std::weak_ptr<PipelineLibrary> library, std::weak_ptr<PipelineLibrary> library,
const PipelineDescriptor& desc, const PipelineDescriptor& desc,
std::shared_ptr<UniqueHandleGLES> handle) std::shared_ptr<UniqueHandleGLES> handle)

View File

@ -38,7 +38,7 @@ class PipelineGLES final
private: private:
friend PipelineLibraryGLES; friend PipelineLibraryGLES;
ReactorGLES::Ref reactor_; std::shared_ptr<ReactorGLES> reactor_;
std::shared_ptr<UniqueHandleGLES> handle_; std::shared_ptr<UniqueHandleGLES> handle_;
std::unique_ptr<BufferBindingsGLES> buffer_bindings_; std::unique_ptr<BufferBindingsGLES> buffer_bindings_;
bool is_valid_ = false; bool is_valid_ = false;
@ -46,7 +46,7 @@ class PipelineGLES final
// |Pipeline| // |Pipeline|
bool IsValid() const override; bool IsValid() const override;
PipelineGLES(ReactorGLES::Ref reactor, PipelineGLES(std::shared_ptr<ReactorGLES> reactor,
std::weak_ptr<PipelineLibrary> library, std::weak_ptr<PipelineLibrary> library,
const PipelineDescriptor& desc, const PipelineDescriptor& desc,
std::shared_ptr<UniqueHandleGLES> handle); std::shared_ptr<UniqueHandleGLES> handle);

View File

@ -16,7 +16,7 @@
namespace impeller { namespace impeller {
PipelineLibraryGLES::PipelineLibraryGLES(ReactorGLES::Ref reactor) PipelineLibraryGLES::PipelineLibraryGLES(std::shared_ptr<ReactorGLES> reactor)
: reactor_(std::move(reactor)) {} : reactor_(std::move(reactor)) {}
static std::string GetShaderInfoLog(const ProcTableGLES& gl, GLuint shader) { static std::string GetShaderInfoLog(const ProcTableGLES& gl, GLuint shader) {
@ -324,7 +324,7 @@ void PipelineLibraryGLES::RemovePipelinesWithEntryPoint(
// |PipelineLibrary| // |PipelineLibrary|
PipelineLibraryGLES::~PipelineLibraryGLES() = default; PipelineLibraryGLES::~PipelineLibraryGLES() = default;
const ReactorGLES::Ref& PipelineLibraryGLES::GetReactor() const { const std::shared_ptr<ReactorGLES>& PipelineLibraryGLES::GetReactor() const {
return reactor_; return reactor_;
} }

View File

@ -87,12 +87,12 @@ class PipelineLibraryGLES final
ProgramKey::Hash, ProgramKey::Hash,
ProgramKey::Equal>; ProgramKey::Equal>;
ReactorGLES::Ref reactor_; std::shared_ptr<ReactorGLES> reactor_;
PipelineMap pipelines_; PipelineMap pipelines_;
Mutex programs_mutex_; Mutex programs_mutex_;
ProgramMap programs_ IPLR_GUARDED_BY(programs_mutex_); ProgramMap programs_ IPLR_GUARDED_BY(programs_mutex_);
explicit PipelineLibraryGLES(ReactorGLES::Ref reactor); explicit PipelineLibraryGLES(std::shared_ptr<ReactorGLES> reactor);
// |PipelineLibrary| // |PipelineLibrary|
bool IsValid() const override; bool IsValid() const override;
@ -113,7 +113,7 @@ class PipelineLibraryGLES final
void RemovePipelinesWithEntryPoint( void RemovePipelinesWithEntryPoint(
std::shared_ptr<const ShaderFunction> function) override; std::shared_ptr<const ShaderFunction> function) override;
const ReactorGLES::Ref& GetReactor() const; const std::shared_ptr<ReactorGLES>& GetReactor() const;
static std::shared_ptr<PipelineGLES> CreatePipeline( static std::shared_ptr<PipelineGLES> CreatePipeline(
const std::weak_ptr<PipelineLibrary>& weak_library, const std::weak_ptr<PipelineLibrary>& weak_library,

View File

@ -85,8 +85,6 @@ class ReactorGLES {
const ReactorGLES& reactor) const = 0; const ReactorGLES& reactor) const = 0;
}; };
using Ref = std::shared_ptr<ReactorGLES>;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
/// @brief Create a new reactor. There are expensive and only one per /// @brief Create a new reactor. There are expensive and only one per
/// application instance is necessary. /// application instance is necessary.

View File

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

View File

@ -24,13 +24,13 @@ class RenderPassGLES final
private: private:
friend class CommandBufferGLES; friend class CommandBufferGLES;
ReactorGLES::Ref reactor_; std::shared_ptr<ReactorGLES> reactor_;
std::string label_; std::string label_;
bool is_valid_ = false; bool is_valid_ = false;
RenderPassGLES(std::shared_ptr<const Context> context, RenderPassGLES(std::shared_ptr<const Context> context,
const RenderTarget& target, const RenderTarget& target,
ReactorGLES::Ref reactor); std::shared_ptr<ReactorGLES> reactor);
// |RenderPass| // |RenderPass|
bool IsValid() const override; bool IsValid() const override;

View File

@ -140,7 +140,8 @@ HandleType ToHandleType(TextureGLES::Type type) {
FML_UNREACHABLE(); FML_UNREACHABLE();
} }
std::shared_ptr<TextureGLES> TextureGLES::WrapFBO(ReactorGLES::Ref reactor, std::shared_ptr<TextureGLES> TextureGLES::WrapFBO(
std::shared_ptr<ReactorGLES> reactor,
TextureDescriptor desc, TextureDescriptor desc,
GLuint fbo) { GLuint fbo) {
auto texture = std::shared_ptr<TextureGLES>( auto texture = std::shared_ptr<TextureGLES>(
@ -152,7 +153,7 @@ std::shared_ptr<TextureGLES> TextureGLES::WrapFBO(ReactorGLES::Ref reactor,
} }
std::shared_ptr<TextureGLES> TextureGLES::WrapTexture( std::shared_ptr<TextureGLES> TextureGLES::WrapTexture(
ReactorGLES::Ref reactor, std::shared_ptr<ReactorGLES> reactor,
TextureDescriptor desc, TextureDescriptor desc,
HandleGLES external_handle) { HandleGLES external_handle) {
if (external_handle.IsDead()) { if (external_handle.IsDead()) {
@ -172,12 +173,13 @@ std::shared_ptr<TextureGLES> TextureGLES::WrapTexture(
} }
std::shared_ptr<TextureGLES> TextureGLES::CreatePlaceholder( std::shared_ptr<TextureGLES> TextureGLES::CreatePlaceholder(
ReactorGLES::Ref reactor, std::shared_ptr<ReactorGLES> reactor,
TextureDescriptor desc) { TextureDescriptor desc) {
return TextureGLES::WrapFBO(std::move(reactor), desc, 0u); return TextureGLES::WrapFBO(std::move(reactor), desc, 0u);
} }
TextureGLES::TextureGLES(ReactorGLES::Ref reactor, TextureDescriptor desc) TextureGLES::TextureGLES(std::shared_ptr<ReactorGLES> reactor,
TextureDescriptor desc)
: TextureGLES(std::move(reactor), // : TextureGLES(std::move(reactor), //
desc, // desc, //
std::nullopt, // std::nullopt, //

View File

@ -39,7 +39,8 @@ class TextureGLES final : public Texture,
/// @return If a texture representation of the framebuffer could be /// @return If a texture representation of the framebuffer could be
/// created. /// created.
/// ///
static std::shared_ptr<TextureGLES> WrapFBO(ReactorGLES::Ref reactor, static std::shared_ptr<TextureGLES> WrapFBO(
std::shared_ptr<ReactorGLES> reactor,
TextureDescriptor desc, TextureDescriptor desc,
GLuint fbo); GLuint fbo);
@ -55,7 +56,8 @@ class TextureGLES final : public Texture,
/// @return If a texture representation of the framebuffer could be /// @return If a texture representation of the framebuffer could be
/// created. /// created.
/// ///
static std::shared_ptr<TextureGLES> WrapTexture(ReactorGLES::Ref reactor, static std::shared_ptr<TextureGLES> WrapTexture(
std::shared_ptr<ReactorGLES> reactor,
TextureDescriptor desc, TextureDescriptor desc,
HandleGLES external_handle); HandleGLES external_handle);
@ -70,10 +72,10 @@ class TextureGLES final : public Texture,
/// @return If a texture placeholder could be created. /// @return If a texture placeholder could be created.
/// ///
static std::shared_ptr<TextureGLES> CreatePlaceholder( static std::shared_ptr<TextureGLES> CreatePlaceholder(
ReactorGLES::Ref reactor, std::shared_ptr<ReactorGLES> reactor,
TextureDescriptor desc); TextureDescriptor desc);
TextureGLES(ReactorGLES::Ref reactor, TextureDescriptor desc); TextureGLES(std::shared_ptr<ReactorGLES> reactor, TextureDescriptor desc);
// |Texture| // |Texture|
~TextureGLES() override; ~TextureGLES() override;
@ -143,7 +145,7 @@ class TextureGLES final : public Texture,
std::optional<HandleGLES> GetSyncFence() const; std::optional<HandleGLES> GetSyncFence() const;
private: private:
ReactorGLES::Ref reactor_; std::shared_ptr<ReactorGLES> reactor_;
const Type type_; const Type type_;
HandleGLES handle_; HandleGLES handle_;
mutable std::optional<HandleGLES> fence_ = std::nullopt; mutable std::optional<HandleGLES> fence_ = std::nullopt;

View File

@ -8,7 +8,8 @@
namespace impeller { namespace impeller {
UniqueHandleGLES::UniqueHandleGLES(ReactorGLES::Ref reactor, HandleType type) UniqueHandleGLES::UniqueHandleGLES(std::shared_ptr<ReactorGLES> reactor,
HandleType type)
: reactor_(std::move(reactor)) { : reactor_(std::move(reactor)) {
if (reactor_) { if (reactor_) {
handle_ = reactor_->CreateHandle(type); handle_ = reactor_->CreateHandle(type);
@ -16,14 +17,16 @@ UniqueHandleGLES::UniqueHandleGLES(ReactorGLES::Ref reactor, HandleType type)
} }
// static // static
UniqueHandleGLES UniqueHandleGLES::MakeUntracked(ReactorGLES::Ref reactor, UniqueHandleGLES UniqueHandleGLES::MakeUntracked(
std::shared_ptr<ReactorGLES> reactor,
HandleType type) { HandleType type) {
FML_DCHECK(reactor); FML_DCHECK(reactor);
HandleGLES handle = reactor->CreateUntrackedHandle(type); HandleGLES handle = reactor->CreateUntrackedHandle(type);
return UniqueHandleGLES(std::move(reactor), handle); return UniqueHandleGLES(std::move(reactor), handle);
} }
UniqueHandleGLES::UniqueHandleGLES(ReactorGLES::Ref reactor, HandleGLES handle) UniqueHandleGLES::UniqueHandleGLES(std::shared_ptr<ReactorGLES> reactor,
HandleGLES handle)
: reactor_(std::move(reactor)), handle_(handle) {} : reactor_(std::move(reactor)), handle_(handle) {}
UniqueHandleGLES::~UniqueHandleGLES() { UniqueHandleGLES::~UniqueHandleGLES() {

View File

@ -17,12 +17,12 @@ namespace impeller {
/// ///
class UniqueHandleGLES { class UniqueHandleGLES {
public: public:
UniqueHandleGLES(ReactorGLES::Ref reactor, HandleType type); UniqueHandleGLES(std::shared_ptr<ReactorGLES> reactor, HandleType type);
static UniqueHandleGLES MakeUntracked(ReactorGLES::Ref reactor, static UniqueHandleGLES MakeUntracked(std::shared_ptr<ReactorGLES> reactor,
HandleType type); HandleType type);
UniqueHandleGLES(ReactorGLES::Ref reactor, HandleGLES handle); UniqueHandleGLES(std::shared_ptr<ReactorGLES> reactor, HandleGLES handle);
~UniqueHandleGLES(); ~UniqueHandleGLES();
@ -37,7 +37,7 @@ class UniqueHandleGLES {
bool IsValid() const; bool IsValid() const;
private: private:
ReactorGLES::Ref reactor_ = nullptr; std::shared_ptr<ReactorGLES> reactor_ = nullptr;
HandleGLES handle_ = HandleGLES::DeadHandle(); HandleGLES handle_ = HandleGLES::DeadHandle();
}; };