| Flutter Impeller |

blit_pass_vk.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "impeller/renderer/backend/vulkan/blit_pass_vk.h"
6
7 #include "flutter/fml/logging.h"
8 #include "flutter/fml/trace_event.h"
9 #include "impeller/renderer/backend/vulkan/command_buffer_vk.h"
10
11 namespace impeller {
12
13 BlitPassVK::BlitPassVK(std::weak_ptr<CommandBufferVK> command_buffer)
14 : command_buffer_(std::move(command_buffer)) {}
15
16 BlitPassVK::~BlitPassVK() = default;
17
18 void BlitPassVK::OnSetLabel(std::string label) {
19 if (label.empty()) {
20 return;
21 }
22 label_ = std::move(label);
23 }
24
25 // |BlitPass|
26 bool BlitPassVK::IsValid() const {
27 return true;
28 }
29
30 // |BlitPass|
31 bool BlitPassVK::EncodeCommands(
32 const std::shared_ptr<Allocator>& transients_allocator) const {
33 TRACE_EVENT0("impeller", "BlitPassVK::EncodeCommands");
34
35 if (!IsValid()) {
36 return false;
37 }
38
39 auto command_buffer = command_buffer_.lock();
40 if (!command_buffer) {
41 return false;
42 }
43 auto encoder = command_buffer->GetEncoder();
44 if (!encoder) {
45 return false;
46 }
47
48 for (auto& command : commands_) {
49 if (!command->Encode(*encoder)) {
50 return false;
51 }
52 }
53
54 return true;
55 }
56
57 // |BlitPass|
58 bool BlitPassVK::OnCopyTextureToTextureCommand(
59 std::shared_ptr<Texture> source,
60 std::shared_ptr<Texture> destination,
61 IRect source_region,
62 IPoint destination_origin,
63 std::string label) {
64 auto command = std::make_unique<BlitCopyTextureToTextureCommandVK>();
65
66 command->source = std::move(source);
67 command->destination = std::move(destination);
68 command->source_region = source_region;
69 command->destination_origin = destination_origin;
70 command->label = std::move(label);
71
72 commands_.push_back(std::move(command));
73 return true;
74 }
75
76 // |BlitPass|
77 bool BlitPassVK::OnCopyTextureToBufferCommand(
78 std::shared_ptr<Texture> source,
79 std::shared_ptr<DeviceBuffer> destination,
80 IRect source_region,
81 size_t destination_offset,
82 std::string label) {
83 auto command = std::make_unique<BlitCopyTextureToBufferCommandVK>();
84
85 command->source = std::move(source);
86 command->destination = std::move(destination);
87 command->source_region = source_region;
88 command->destination_offset = destination_offset;
89 command->label = std::move(label);
90
91 commands_.push_back(std::move(command));
92 return true;
93 }
94
95 // |BlitPass|
96 bool BlitPassVK::OnCopyBufferToTextureCommand(
97 BufferView source,
98 std::shared_ptr<Texture> destination,
99 IPoint destination_origin,
100 std::string label) {
101 auto command = std::make_unique<BlitCopyBufferToTextureCommandVK>();
102
103 command->source = std::move(source);
104 command->destination = std::move(destination);
105 command->destination_origin = destination_origin;
106 command->label = std::move(label);
107
108 commands_.push_back(std::move(command));
109 return true;
110 }
111
112 // |BlitPass|
113 bool BlitPassVK::OnGenerateMipmapCommand(std::shared_ptr<Texture> texture,
114 std::string label) {
115 auto command = std::make_unique<BlitGenerateMipmapCommandVK>();
116
117 command->texture = std::move(texture);
118 command->label = std::move(label);
119
120 commands_.push_back(std::move(command));
121 return true;
122 }
123
124 } // namespace impeller
command_buffer_vk.h
impeller::BlitPassVK::~BlitPassVK
~BlitPassVK() override
blit_pass_vk.h
impeller::IRect
TRect< int64_t > IRect
Definition: rect.h:489
std
Definition: comparable.h:95
impeller::IPoint
TPoint< int64_t > IPoint
Definition: point.h:309
impeller
Definition: aiks_context.cc:10