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 {
AllocatorGLES::AllocatorGLES(ReactorGLES::Ref reactor)
AllocatorGLES::AllocatorGLES(std::shared_ptr<ReactorGLES> reactor)
: reactor_(std::move(reactor)), is_valid_(true) {}
// |Allocator|

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,7 +35,7 @@ class ContextGLES final : public Context,
// |Context|
BackendType GetBackendType() const override;
const ReactorGLES::Ref& GetReactor() const;
const std::shared_ptr<ReactorGLES>& GetReactor() const;
std::optional<ReactorGLES::WorkerID> AddReactorWorker(
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_; }
private:
ReactorGLES::Ref reactor_;
std::shared_ptr<ReactorGLES> reactor_;
std::shared_ptr<ShaderLibraryGLES> shader_library_;
std::shared_ptr<PipelineLibraryGLES> pipeline_library_;
std::shared_ptr<SamplerLibraryGLES> sampler_library_;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -140,9 +140,10 @@ HandleType ToHandleType(TextureGLES::Type type) {
FML_UNREACHABLE();
}
std::shared_ptr<TextureGLES> TextureGLES::WrapFBO(ReactorGLES::Ref reactor,
TextureDescriptor desc,
GLuint fbo) {
std::shared_ptr<TextureGLES> TextureGLES::WrapFBO(
std::shared_ptr<ReactorGLES> reactor,
TextureDescriptor desc,
GLuint fbo) {
auto texture = std::shared_ptr<TextureGLES>(
new TextureGLES(std::move(reactor), desc, fbo, std::nullopt));
if (!texture->IsValid()) {
@ -152,7 +153,7 @@ std::shared_ptr<TextureGLES> TextureGLES::WrapFBO(ReactorGLES::Ref reactor,
}
std::shared_ptr<TextureGLES> TextureGLES::WrapTexture(
ReactorGLES::Ref reactor,
std::shared_ptr<ReactorGLES> reactor,
TextureDescriptor desc,
HandleGLES external_handle) {
if (external_handle.IsDead()) {
@ -172,12 +173,13 @@ std::shared_ptr<TextureGLES> TextureGLES::WrapTexture(
}
std::shared_ptr<TextureGLES> TextureGLES::CreatePlaceholder(
ReactorGLES::Ref reactor,
std::shared_ptr<ReactorGLES> reactor,
TextureDescriptor desc) {
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), //
desc, //
std::nullopt, //

View File

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

View File

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

View File

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