9#include "flutter/fml/trace_event.h"
18 : reactor_(
std::move(reactor)),
19 is_valid_(reactor_ && reactor_->IsValid()) {}
22BlitPassGLES::~BlitPassGLES() =
default;
25bool BlitPassGLES::IsValid()
const {
30void 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");
48 [&
gl]() {
gl.PopDebugGroup(); });
50 gl.PushDebugGroup(label);
52 pop_pass_debug_marker.Release();
57 [&
gl]() {
gl.PopDebugGroup(); });
58 auto label =
command->GetLabel();
60 gl.PushDebugGroup(label);
62 pop_cmd_debug_marker.Release();
65 if (!
command->Encode(reactor)) {
74bool 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.";
94bool BlitPassGLES::OnCopyTextureToTextureCommand(
95 std::shared_ptr<Texture>
source,
96 std::shared_ptr<Texture> destination,
100 auto command = std::make_unique<BlitCopyTextureToTextureCommandGLES>();
103 command->destination = std::move(destination);
104 command->source_region = source_region;
105 command->destination_origin = destination_origin;
107 commands_.push_back(std::move(
command));
112bool 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>();
121 command->destination = std::move(destination);
122 command->source_region = source_region;
123 command->destination_offset = destination_offset;
125 commands_.push_back(std::move(
command));
130bool BlitPassGLES::OnCopyBufferToTextureCommand(
132 std::shared_ptr<Texture> destination,
133 IRect destination_region,
136 bool convert_to_read) {
137 auto command = std::make_unique<BlitCopyBufferToTextureCommandGLES>();
140 command->destination = std::move(destination);
141 command->destination_region = destination_region;
145 commands_.push_back(std::move(
command));
150bool BlitPassGLES::OnGenerateMipmapCommand(std::shared_ptr<Texture>
texture,
152 auto command = std::make_unique<BlitGenerateMipmapCommandGLES>();
156 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.
std::shared_ptr< ReactorGLES > Ref
#define FML_CHECK(condition)
bool EncodeCommandsInReactor(const std::shared_ptr< Allocator > &transients_allocator, const ReactorGLES &reactor, const std::vector< std::unique_ptr< BlitEncodeGLES > > &commands, const std::string &label)
#define TRACE_EVENT0(category_group, name)