9 #include "flutter/fml/trace_event.h"
10 #include "fml/closure.h"
18 : reactor_(
std::move(reactor)),
19 is_valid_(reactor_ && reactor_->IsValid()) {}
25 bool BlitPassGLES::IsValid()
const {
30 void BlitPassGLES::OnSetLabel(std::string label) {
31 label_ = std::move(label);
35 const std::shared_ptr<Allocator>& transients_allocator,
37 const std::vector<std::unique_ptr<BlitEncodeGLES>>& commands,
38 const std::string& label) {
39 TRACE_EVENT0(
"impeller",
"BlitPassGLES::EncodeCommandsInReactor");
41 if (commands.empty()) {
47 fml::ScopedCleanupClosure pop_pass_debug_marker(
48 [&gl]() { gl.PopDebugGroup(); });
52 pop_pass_debug_marker.Release();
55 for (
const auto& command : commands) {
56 fml::ScopedCleanupClosure pop_cmd_debug_marker(
57 [&gl]() { gl.PopDebugGroup(); });
58 auto label = command->GetLabel();
60 gl.PushDebugGroup(label);
62 pop_cmd_debug_marker.Release();
65 if (!command->Encode(reactor)) {
74 bool BlitPassGLES::EncodeCommands(
75 const std::shared_ptr<Allocator>& transients_allocator)
const {
79 if (commands_.empty()) {
83 std::shared_ptr<const BlitPassGLES> shared_this = shared_from_this();
84 return reactor_->AddOperation([transients_allocator,
85 blit_pass = std::move(shared_this),
86 label = label_](
const auto& reactor) {
88 blit_pass->commands_, label);
89 FML_CHECK(result) <<
"Must be able to encode GL commands without error.";
94 bool BlitPassGLES::OnCopyTextureToTextureCommand(
95 std::shared_ptr<Texture> source,
96 std::shared_ptr<Texture> destination,
100 auto command = std::make_unique<BlitCopyTextureToTextureCommandGLES>();
101 command->label = label;
102 command->source = std::move(source);
103 command->destination = std::move(destination);
104 command->source_region = source_region;
105 command->destination_origin = destination_origin;
107 commands_.emplace_back(std::move(command));
112 bool BlitPassGLES::OnCopyTextureToBufferCommand(
113 std::shared_ptr<Texture> source,
114 std::shared_ptr<DeviceBuffer> destination,
116 size_t destination_offset,
118 auto command = std::make_unique<BlitCopyTextureToBufferCommandGLES>();
119 command->label = label;
120 command->source = std::move(source);
121 command->destination = std::move(destination);
122 command->source_region = source_region;
123 command->destination_offset = destination_offset;
125 commands_.emplace_back(std::move(command));
130 bool BlitPassGLES::OnGenerateMipmapCommand(std::shared_ptr<Texture> texture,
132 auto command = std::make_unique<BlitGenerateMipmapCommandGLES>();
133 command->label = label;
134 command->texture = std::move(texture);
136 commands_.emplace_back(std::move(command));