15 const std::vector<std::shared_ptr<CommandBuffer>>& buffers,
17 if (completion_callback) {
24 return std::shared_ptr<ContextSpy>(
new ContextSpy());
28 const std::shared_ptr<Context>& real_context) {
30 std::make_shared<::testing::NiceMock<ContextMock>>();
31 std::shared_ptr<ContextSpy> shared_this = shared_from_this();
33 ON_CALL(*
mock_context, IsValid).WillByDefault([real_context]() {
34 return real_context->IsValid();
39 return real_context->GetBackendType();
44 [real_context]() ->
const std::shared_ptr<const Capabilities>& {
45 return real_context->GetCapabilities();
50 return real_context->UpdateOffscreenLayerPixelFormat(
format);
53 ON_CALL(*
mock_context, GetResourceAllocator).WillByDefault([real_context]() {
54 return real_context->GetResourceAllocator();
57 ON_CALL(*
mock_context, GetShaderLibrary).WillByDefault([real_context]() {
58 return real_context->GetShaderLibrary();
61 ON_CALL(*
mock_context, GetSamplerLibrary).WillByDefault([real_context]() {
62 return real_context->GetSamplerLibrary();
65 ON_CALL(*
mock_context, GetPipelineLibrary).WillByDefault([real_context]() {
66 return real_context->GetPipelineLibrary();
69 ON_CALL(*
mock_context, GetCommandQueue).WillByDefault([shared_this]() {
70 return shared_this->command_queue_;
74 .WillByDefault([real_context, shared_this]() {
75 auto real_buffer = real_context->CreateCommandBuffer();
76 auto spy = std::make_shared<::testing::NiceMock<CommandBufferMock>>(
79 ON_CALL(*spy, IsValid).WillByDefault([real_buffer]() {
80 return real_buffer->IsValid();
83 ON_CALL(*spy, SetLabel)
84 .WillByDefault([real_buffer](
const std::string& label) {
85 return real_buffer->SetLabel(label);
88 ON_CALL(*spy, OnCreateRenderPass)
89 .WillByDefault([real_buffer, shared_this,
91 std::shared_ptr<RenderPass>
result =
93 real_buffer.get(), render_target);
94 std::shared_ptr<RecordingRenderPass> recorder =
95 std::make_shared<RecordingRenderPass>(
result, real_context,
97 shared_this->render_passes_.push_back(recorder);
101 ON_CALL(*spy, OnCreateBlitPass).WillByDefault([real_buffer]() {
105 ON_CALL(*spy, OnSubmitCommands)
109 real_buffer.get(), std::move(
callback));
112 ON_CALL(*spy, OnWaitUntilScheduled).WillByDefault([real_buffer]() {
117 ON_CALL(*spy, OnCreateComputePass).WillByDefault([real_buffer]() {
std::function< void(Status)> CompletionCallback
std::function< void(CommandBuffer::Status)> CompletionCallback
static std::shared_ptr< BlitPass > ForwardOnCreateBlitPass(CommandBuffer *command_buffer)
static std::shared_ptr< RenderPass > ForwardOnCreateRenderPass(CommandBuffer *command_buffer, const RenderTarget &render_target)
static std::shared_ptr< ComputePass > ForwardOnCreateComputePass(CommandBuffer *command_buffer)
static bool ForwardOnSubmitCommands(CommandBuffer *command_buffer, CompletionCallback callback)
static void ForwardOnWaitUntilScheduled(CommandBuffer *command_buffer)
static std::shared_ptr< ContextSpy > Make()
std::shared_ptr< ContextMock > MakeContext(const std::shared_ptr< Context > &real_context)
fml::Status Submit(const std::vector< std::shared_ptr< CommandBuffer > > &buffers, const CompletionCallback &completion_callback={}) override
Submit one or more command buffer objects to be encoded and executed on the GPU.
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
uint32_t uint32_t * format
static MockContext mock_context
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
static id< MTLCommandBuffer > CreateCommandBuffer(id< MTLCommandQueue > queue)