9 #include "flutter/fml/trace_event.h"
10 #include "fml/closure.h"
17 BlitPassGLES::BlitPassGLES(std::shared_ptr<ReactorGLES> reactor)
18 : reactor_(
std::move(reactor)),
19 is_valid_(reactor_ && reactor_->IsValid()) {}
22 BlitPassGLES::~BlitPassGLES() =
default;
25 bool BlitPassGLES::IsValid()
const {
30 void 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()) {
46 fml::ScopedCleanupClosure pop_pass_debug_marker(
47 [&gl]() { gl.PopDebugGroup(); });
51 pop_pass_debug_marker.Release();
55 for (
const auto& command : commands) {
57 fml::ScopedCleanupClosure pop_cmd_debug_marker(
58 [&gl]() { gl.PopDebugGroup(); });
59 auto label = command->GetLabel();
61 gl.PushDebugGroup(label);
63 pop_cmd_debug_marker.Release();
67 if (!command->Encode(reactor)) {
76 bool 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.";
93 bool BlitPassGLES::OnCopyTextureToTextureCommand(
94 std::shared_ptr<Texture> source,
95 std::shared_ptr<Texture> destination,
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));
111 bool 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));
129 bool 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));
151 bool 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));
162 bool 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));
void PushDebugGroup(const std::string &string) const
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.
bool EncodeCommandsInReactor(const ReactorGLES &reactor, const std::vector< std::unique_ptr< BlitEncodeGLES >> &commands, const std::string &label)