Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
context_mock.h
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#ifndef FLUTTER_IMPELLER_AIKS_TESTING_CONTEXT_MOCK_H_
6#define FLUTTER_IMPELLER_AIKS_TESTING_CONTEXT_MOCK_H_
7
8#include <string>
9#include <utility>
10#include <vector>
11
12#include "gmock/gmock-function-mocker.h"
13#include "gmock/gmock.h"
17
18namespace impeller {
19namespace testing {
20
22 public:
23 explicit CommandBufferMock(std::weak_ptr<const Context> context)
24 : CommandBuffer(std::move(context)) {}
25
26 MOCK_METHOD(bool, IsValid, (), (const, override));
27
28 MOCK_METHOD(void, SetLabel, (const std::string& label), (const, override));
29
30 MOCK_METHOD(std::shared_ptr<RenderPass>,
32 (RenderTarget render_target),
33 (override));
34
35 static std::shared_ptr<RenderPass> ForwardOnCreateRenderPass(
36 CommandBuffer* command_buffer,
37 const RenderTarget& render_target) {
38 return command_buffer->OnCreateRenderPass(render_target);
39 }
40
41 MOCK_METHOD(std::shared_ptr<BlitPass>, OnCreateBlitPass, (), (override));
42 static std::shared_ptr<BlitPass> ForwardOnCreateBlitPass(
43 CommandBuffer* command_buffer) {
44 return command_buffer->OnCreateBlitPass();
45 }
46
50 (override));
51 static bool ForwardOnSubmitCommands(CommandBuffer* command_buffer,
53 return command_buffer->OnSubmitCommands(std::move(callback));
54 }
55
56 MOCK_METHOD(void, OnWaitUntilScheduled, (), (override));
57 static void ForwardOnWaitUntilScheduled(CommandBuffer* command_buffer) {
58 return command_buffer->OnWaitUntilScheduled();
59 }
60
61 MOCK_METHOD(std::shared_ptr<ComputePass>,
63 (),
64 (override));
65 static std::shared_ptr<ComputePass> ForwardOnCreateComputePass(
66 CommandBuffer* command_buffer) {
67 return command_buffer->OnCreateComputePass();
68 }
69};
70
71class ContextMock : public Context {
72 public:
73 MOCK_METHOD(std::string, DescribeGpuModel, (), (const, override));
74
76
77 MOCK_METHOD(bool, IsValid, (), (const, override));
78
79 MOCK_METHOD(const std::shared_ptr<const Capabilities>&,
81 (),
82 (const, override));
83
87 (override));
88
89 MOCK_METHOD(std::shared_ptr<Allocator>,
91 (),
92 (const, override));
93
94 MOCK_METHOD(std::shared_ptr<ShaderLibrary>,
96 (),
97 (const, override));
98
99 MOCK_METHOD(std::shared_ptr<SamplerLibrary>,
101 (),
102 (const, override));
103
104 MOCK_METHOD(std::shared_ptr<PipelineLibrary>,
106 (),
107 (const, override));
108
109 MOCK_METHOD(std::shared_ptr<CommandBuffer>,
111 (),
112 (const, override));
113
114 MOCK_METHOD(std::shared_ptr<CommandQueue>,
116 (),
117 (const override));
118
119 MOCK_METHOD(void, Shutdown, (), (override));
120
123 (),
124 (const, override));
125};
126
127} // namespace testing
128} // namespace impeller
129
130#endif // FLUTTER_IMPELLER_AIKS_TESTING_CONTEXT_MOCK_H_
A collection of encoded commands to be submitted to the GPU for execution. A command buffer is obtain...
virtual std::shared_ptr< BlitPass > OnCreateBlitPass()=0
virtual void SetLabel(const std::string &label) const =0
virtual bool IsValid() const =0
virtual std::shared_ptr< ComputePass > OnCreateComputePass()=0
virtual bool OnSubmitCommands(CompletionCallback callback)=0
std::function< void(Status)> CompletionCallback
virtual void OnWaitUntilScheduled()=0
virtual std::shared_ptr< RenderPass > OnCreateRenderPass(RenderTarget render_target)=0
To do anything rendering related with Impeller, you need a context.
Definition context.h:46
virtual std::shared_ptr< CommandQueue > GetCommandQueue() const =0
Return the graphics queue for submitting command buffers.
virtual const std::shared_ptr< const Capabilities > & GetCapabilities() const =0
Get the capabilities of Impeller context. All optionally supported feature of the platform,...
virtual BackendType GetBackendType() const =0
Get the graphics backend of an Impeller context.
virtual std::shared_ptr< PipelineLibrary > GetPipelineLibrary() const =0
Returns the library of pipelines used by render or compute commands.
virtual void Shutdown()=0
Force all pending asynchronous work to finish. This is achieved by deleting all owned concurrent mess...
virtual std::shared_ptr< ShaderLibrary > GetShaderLibrary() const =0
Returns the library of shaders used to specify the programmable stages of a pipeline.
virtual std::shared_ptr< SamplerLibrary > GetSamplerLibrary() const =0
Returns the library of combined image samplers used in shaders.
virtual std::shared_ptr< CommandBuffer > CreateCommandBuffer() const =0
Create a new command buffer. Command buffers can be used to encode graphics, blit,...
virtual void InitializeCommonlyUsedShadersIfNeeded() const
Definition context.h:195
virtual std::string DescribeGpuModel() const =0
virtual bool UpdateOffscreenLayerPixelFormat(PixelFormat format)
Definition context.cc:15
virtual std::shared_ptr< Allocator > GetResourceAllocator() const =0
Returns the allocator used to create textures and buffers on the device.
virtual bool IsValid() const =0
Determines if a context is valid. If the caller ever receives an invalid context, they must discard i...
static std::shared_ptr< BlitPass > ForwardOnCreateBlitPass(CommandBuffer *command_buffer)
MOCK_METHOD(void, SetLabel,(const std::string &label),(const, override))
static std::shared_ptr< RenderPass > ForwardOnCreateRenderPass(CommandBuffer *command_buffer, const RenderTarget &render_target)
MOCK_METHOD(void, OnWaitUntilScheduled,(),(override))
MOCK_METHOD(std::shared_ptr< ComputePass >, OnCreateComputePass,(),(override))
static std::shared_ptr< ComputePass > ForwardOnCreateComputePass(CommandBuffer *command_buffer)
MOCK_METHOD(std::shared_ptr< RenderPass >, OnCreateRenderPass,(RenderTarget render_target),(override))
MOCK_METHOD(std::shared_ptr< BlitPass >, OnCreateBlitPass,(),(override))
CommandBufferMock(std::weak_ptr< const Context > context)
static bool ForwardOnSubmitCommands(CommandBuffer *command_buffer, CompletionCallback callback)
MOCK_METHOD(bool, IsValid,(),(const, override))
MOCK_METHOD(bool, OnSubmitCommands,(CompletionCallback callback),(override))
static void ForwardOnWaitUntilScheduled(CommandBuffer *command_buffer)
MOCK_METHOD(std::shared_ptr< CommandQueue >, GetCommandQueue,(),(const override))
MOCK_METHOD(std::shared_ptr< PipelineLibrary >, GetPipelineLibrary,(),(const, override))
MOCK_METHOD(std::shared_ptr< Allocator >, GetResourceAllocator,(),(const, override))
MOCK_METHOD(std::string, DescribeGpuModel,(),(const, override))
MOCK_METHOD(std::shared_ptr< CommandBuffer >, CreateCommandBuffer,(),(const, override))
MOCK_METHOD(std::shared_ptr< ShaderLibrary >, GetShaderLibrary,(),(const, override))
MOCK_METHOD(bool, IsValid,(),(const, override))
MOCK_METHOD(std::shared_ptr< SamplerLibrary >, GetSamplerLibrary,(),(const, override))
MOCK_METHOD(void, Shutdown,(),(override))
MOCK_METHOD(const std::shared_ptr< const Capabilities > &, GetCapabilities,(),(const, override))
MOCK_METHOD(Context::BackendType, GetBackendType,(),(const, override))
MOCK_METHOD(bool, UpdateOffscreenLayerPixelFormat,(PixelFormat format),(override))
MOCK_METHOD(void, InitializeCommonlyUsedShadersIfNeeded,(),(const, override))
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
uint32_t uint32_t * format
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition formats.h:100
Definition ref_ptr.h:256