7#include "gmock/gmock.h"
8#include "gtest/gtest.h"
25using ::testing::ElementsAreArray;
26using ::testing::NiceMock;
27using ::testing::Return;
28using ::testing::SetArgPointee;
29using ::testing::TestWithParam;
31class TestReactorGLES :
public ReactorGLES {
56 :
public TestWithParam<DiscardFrameBufferParams> {};
59std::shared_ptr<ContextGLES> CreateFakeGLESContext() {
61 auto dummy_shader_library = std::vector<std::shared_ptr<fml::Mapping>>{};
64 dummy_shader_library,
false);
69 auto mock_gl_impl = std::make_unique<NiceMock<MockGLESImpl>>();
70 auto& mock_gl_impl_ref = *mock_gl_impl;
72 MockGLES::Init(std::move(mock_gl_impl), {{
"GL_EXT_discard_framebuffer"}});
74 auto context = CreateFakeGLESContext();
75 auto dummy_worker = std::make_shared<MockWorker>();
76 context->AddReactorWorker(dummy_worker);
77 auto reactor = context->GetReactor();
79 const auto command_buffer =
80 std::static_pointer_cast<Context>(context)->CreateCommandBuffer();
85 const auto& test_params = GetParam();
86 auto framebuffer_texture =
91 render_target.SetColorAttachment(color_attachment, 0);
92 const auto render_pass = command_buffer->CreateRenderPass(render_target);
94 EXPECT_CALL(mock_gl_impl_ref, GetIntegerv(GL_FRAMEBUFFER_BINDING, _))
95 .WillOnce(SetArgPointee<1>(test_params.frame_buffer_id));
97 EXPECT_CALL(mock_gl_impl_ref, DiscardFramebufferEXT(GL_FRAMEBUFFER, _, _))
98 .With(Args<2, 1>(ElementsAreArray(test_params.expected_attachments)))
100 ASSERT_TRUE(render_pass->EncodeCommands());
101 ASSERT_TRUE(reactor->React());
107 ::testing::ValuesIn(std::vector<DiscardFrameBufferParams>{
108 {.frame_buffer_id = 0,
109 .expected_attachments = {GL_COLOR_EXT, GL_DEPTH_EXT, GL_STENCIL_EXT}},
110 {.frame_buffer_id = 1,
111 .expected_attachments = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT,
112 GL_STENCIL_ATTACHMENT}}}),
113 [](const ::testing::TestParamInfo<DiscardFrameBufferParams>& info) {
114 return (info.param.frame_buffer_id == 0) ?
"Default" :
"NonDefault";
static std::shared_ptr< ContextGLES > Create(const Flags &flags, std::unique_ptr< ProcTableGLES > gl, const std::vector< std::shared_ptr< fml::Mapping > > &shader_libraries, bool enable_gpu_tracing)
A delegate implemented by a thread on which an OpenGL context is current. There may be multiple worke...
The reactor attempts to make thread-safe usage of OpenGL ES easier to reason about.
static std::shared_ptr< TextureGLES > WrapFBO(std::shared_ptr< ReactorGLES > reactor, TextureDescriptor desc, GLuint fbo)
Create a texture by wrapping an external framebuffer object whose lifecycle is owned by the caller.
static std::shared_ptr< MockGLES > Init(std::unique_ptr< MockGLESImpl > impl, const std::optional< std::vector< const char * > > &extensions=std::nullopt)
bool CanReactorReactOnCurrentThreadNow(const ReactorGLES &reactor) const override
Determines the ability of the worker to service a reaction on the current thread. The OpenGL context ...
~TestReactorGLES()=default
TEST_P(AiksTest, DrawAtlasNoColor)
const ProcTableGLES::Resolver kMockResolverGLES
INSTANTIATE_TEST_SUITE_P(FrameBufferObject, RenderPassGLESWithDiscardFrameBufferExtTest, ::testing::ValuesIn(std::vector< DiscardFrameBufferParams >{ {.frame_buffer_id=0,.expected_attachments={GL_COLOR_EXT, GL_DEPTH_EXT, GL_STENCIL_EXT}}, {.frame_buffer_id=1,.expected_attachments={GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT}}}), [](const ::testing::TestParamInfo< DiscardFrameBufferParams > &info) { return(info.param.frame_buffer_id==0) ? "Default" :"NonDefault";})
std::shared_ptr< Texture > texture
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
std::array< GLenum, 3 > expected_attachments