28 {
30 std::make_shared<::testing::NiceMock<ContextMock>>();
31 std::shared_ptr<ContextSpy> shared_this = shared_from_this();
32
33 ON_CALL(*
mock_context, IsValid).WillByDefault([real_context]() {
34 return real_context->IsValid();
35 });
36
39 return real_context->GetBackendType();
40 });
41
43 .WillByDefault(
44 [real_context]() -> const std::shared_ptr<const Capabilities>& {
45 return real_context->GetCapabilities();
46 });
47
50 return real_context->UpdateOffscreenLayerPixelFormat(
format);
51 });
52
53 ON_CALL(*
mock_context, GetResourceAllocator).WillByDefault([real_context]() {
54 return real_context->GetResourceAllocator();
55 });
56
57 ON_CALL(*
mock_context, GetShaderLibrary).WillByDefault([real_context]() {
58 return real_context->GetShaderLibrary();
59 });
60
61 ON_CALL(*
mock_context, GetSamplerLibrary).WillByDefault([real_context]() {
62 return real_context->GetSamplerLibrary();
63 });
64
65 ON_CALL(*
mock_context, GetPipelineLibrary).WillByDefault([real_context]() {
66 return real_context->GetPipelineLibrary();
67 });
68
69 ON_CALL(*
mock_context, GetCommandQueue).WillByDefault([shared_this]() {
70 return shared_this->command_queue_;
71 });
72
74 .WillByDefault([real_context, shared_this]() {
75 auto real_buffer = real_context->CreateCommandBuffer();
76 auto spy = std::make_shared<::testing::NiceMock<CommandBufferMock>>(
77 real_context);
78
79 ON_CALL(*spy, IsValid).WillByDefault([real_buffer]() {
80 return real_buffer->IsValid();
81 });
82
83 ON_CALL(*spy, SetLabel)
84 .WillByDefault([real_buffer](const std::string& label) {
85 return real_buffer->SetLabel(label);
86 });
87
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,
96 render_target);
97 shared_this->render_passes_.push_back(recorder);
98 return recorder;
99 });
100
101 ON_CALL(*spy, OnCreateBlitPass).WillByDefault([real_buffer]() {
103 });
104
105 ON_CALL(*spy, OnSubmitCommands)
106 .WillByDefault(
109 real_buffer.get(), std::move(
callback));
110 });
111
112 ON_CALL(*spy, OnWaitUntilScheduled).WillByDefault([real_buffer]() {
114 real_buffer.get());
115 });
116
117 ON_CALL(*spy, OnCreateComputePass).WillByDefault([real_buffer]() {
119 real_buffer.get());
120 });
121
122 return spy;
123 });
124
126}
std::function< void(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)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
uint32_t uint32_t * format
static MockContext mock_context
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
static id< MTLCommandBuffer > CreateCommandBuffer(id< MTLCommandQueue > queue)