17BlitPassGLES::BlitPassGLES(std::shared_ptr<ReactorGLES> reactor)
18 : reactor_(
std::move(reactor)),
19 is_valid_(reactor_ && reactor_->IsValid()) {}
22BlitPassGLES::~BlitPassGLES() =
default;
25bool BlitPassGLES::IsValid()
const {
30void BlitPassGLES::OnSetLabel(std::string_view label) {
31 label_ = std::string(label);
36 const std::vector<std::unique_ptr<BlitEncodeGLES>>& commands,
37 const std::string& label) {
38 TRACE_EVENT0(
"impeller",
"BlitPassGLES::EncodeCommandsInReactor");
40 if (commands.empty()) {
47 [&gl]() { gl.PopDebugGroup(); });
49 gl.PushDebugGroup(label);
51 pop_pass_debug_marker.
Release();
55 for (
const auto& command : commands) {
58 [&gl]() { gl.PopDebugGroup(); });
59 auto label = command->GetLabel();
61 gl.PushDebugGroup(label);
67 if (!command->Encode(reactor)) {
76bool BlitPassGLES::EncodeCommands()
const {
80 if (commands_.empty()) {
84 std::shared_ptr<const BlitPassGLES> shared_this = shared_from_this();
85 return reactor_->AddOperation([blit_pass = std::move(shared_this),
86 label = label_](
const auto& reactor) {
88 FML_CHECK(result) <<
"Must be able to encode GL commands without error.";
93bool BlitPassGLES::OnCopyTextureToTextureCommand(
94 std::shared_ptr<Texture> source,
95 std::shared_ptr<Texture> destination,
97 IPoint destination_origin,
98 std::string_view label) {
99 auto command = std::make_unique<BlitCopyTextureToTextureCommandGLES>();
100 command->label = label;
101 command->source = std::move(source);
102 command->destination = std::move(destination);
103 command->source_region = source_region;
104 command->destination_origin = destination_origin;
106 commands_.push_back(std::move(command));
111bool BlitPassGLES::OnCopyTextureToBufferCommand(
112 std::shared_ptr<Texture> source,
113 std::shared_ptr<DeviceBuffer> destination,
115 size_t destination_offset,
116 std::string_view label) {
117 auto command = std::make_unique<BlitCopyTextureToBufferCommandGLES>();
118 command->label = label;
119 command->source = std::move(source);
120 command->destination = std::move(destination);
121 command->source_region = source_region;
122 command->destination_offset = destination_offset;
124 commands_.push_back(std::move(command));
129bool BlitPassGLES::OnCopyBufferToTextureCommand(
131 std::shared_ptr<Texture> destination,
132 IRect destination_region,
133 std::string_view label,
136 bool convert_to_read) {
137 auto command = std::make_unique<BlitCopyBufferToTextureCommandGLES>();
138 command->label = label;
139 command->source = std::move(source);
140 command->destination = std::move(destination);
141 command->destination_region = destination_region;
142 command->label = label;
143 command->mip_level = mip_level;
144 command->slice = slice;
146 commands_.push_back(std::move(command));
151bool BlitPassGLES::OnGenerateMipmapCommand(std::shared_ptr<Texture>
texture,
152 std::string_view label) {
153 auto command = std::make_unique<BlitGenerateMipmapCommandGLES>();
154 command->label = label;
155 command->texture = std::move(
texture);
157 commands_.push_back(std::move(command));
162bool BlitPassGLES::ResizeTexture(
const std::shared_ptr<Texture>& source,
163 const std::shared_ptr<Texture>& destination) {
164 auto command = std::make_unique<BlitResizeTextureCommandGLES>();
165 command->source = source;
166 command->destination = destination;
168 commands_.push_back(std::move(command));
Wraps a closure that is invoked in the destructor unless released by the caller.
The reactor attempts to make thread-safe usage of OpenGL ES easier to reason about.
const ProcTableGLES & GetProcTable() const
Get the OpenGL proc. table the reactor uses to manage handles.
#define FML_CHECK(condition)
bool EncodeCommandsInReactor(const ReactorGLES &reactor, const std::vector< std::unique_ptr< BlitEncodeGLES > > &commands, const std::string &label)
#define TRACE_EVENT0(category_group, name)