7#include "gtest/gtest.h"
40 ::testing::NiceMock<flutter::testing::MockEpoxy>
epoxy;
49 constexpr size_t width = 100;
50 constexpr size_t height = 100;
55 .open_gl = {.framebuffer = {.user_data =
framebuffer}}};
57 .backing_store = &backing_store,
65 size_t frame_width, frame_height;
68 EXPECT_EQ(frame_width,
width);
69 EXPECT_EQ(frame_height,
height);
72 int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
width);
73 g_autofree
unsigned char* image_data =
74 static_cast<unsigned char*
>(malloc(
height * stride));
75 cairo_surface_t*
surface = cairo_image_surface_create_for_data(
76 image_data, CAIRO_FORMAT_ARGB32,
width,
height, stride);
77 cairo_t* cr = cairo_create(
surface);
85 constexpr size_t width1 = 90;
86 constexpr size_t height1 = 90;
91 .open_gl = {.framebuffer = {.user_data = framebuffer1}}};
93 .backing_store = &backing_store1,
95 .size = {width1, height1}};
102 constexpr size_t width2 = 100;
103 constexpr size_t height2 = 100;
108 .open_gl = {.framebuffer = {.user_data = framebuffer2}}};
110 .backing_store = &backing_store2,
112 .size = {width2, height2}};
121 int stride2 = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width2);
122 g_autofree
unsigned char* image_data =
123 static_cast<unsigned char*
>(malloc(height2 * stride2));
124 cairo_surface_t*
surface = cairo_image_surface_create_for_data(
125 image_data, CAIRO_FORMAT_ARGB32, width2, height2, stride2);
126 cairo_t* cr = cairo_create(
surface);
128 cairo_surface_destroy(
surface);
135 constexpr size_t width = 100;
136 constexpr size_t height = 100;
139 ON_CALL(epoxy, glGetString(GL_VENDOR))
141 ::testing::Return(
reinterpret_cast<const GLubyte*
>(
"Intel")));
149 .open_gl = {.framebuffer = {.user_data =
framebuffer}}};
151 .backing_store = &backing_store,
156 constexpr GLuint kFakeTextureName = 123;
159 glEnable(GL_SCISSOR_TEST);
165 int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
width);
166 g_autofree
unsigned char* image_data =
167 static_cast<unsigned char*
>(malloc(
height * stride));
168 cairo_surface_t*
surface = cairo_image_surface_create_for_data(
169 image_data, CAIRO_FORMAT_ARGB32,
width,
height, stride);
170 cairo_t* cr = cairo_create(
surface);
172 cairo_surface_destroy(
surface);
175 GLuint texture_2d_binding;
176 glGetIntegerv(GL_TEXTURE_BINDING_2D,
177 reinterpret_cast<GLint*
>(&texture_2d_binding));
178 EXPECT_EQ(texture_2d_binding, kFakeTextureName);
179 EXPECT_EQ(glIsEnabled(GL_BLEND), GL_FALSE);
180 EXPECT_EQ(glIsEnabled(GL_SCISSOR_TEST), GL_TRUE);
184 constexpr size_t width = 100;
185 constexpr size_t height = 100;
188 ON_CALL(epoxy, glGetString(GL_VENDOR))
190 ::testing::Return(
reinterpret_cast<const GLubyte*
>(
"Intel")));
194 EXPECT_CALL(epoxy, glBlitFramebuffer);
200 .open_gl = {.framebuffer = {.user_data =
framebuffer}}};
202 .backing_store = &backing_store,
211 int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
width);
212 g_autofree
unsigned char* image_data =
213 static_cast<unsigned char*
>(malloc(
height * stride));
214 cairo_surface_t*
surface = cairo_image_surface_create_for_data(
215 image_data, CAIRO_FORMAT_ARGB32,
width,
height, stride);
216 cairo_t* cr = cairo_create(
surface);
218 cairo_surface_destroy(
surface);
223 constexpr size_t width = 100;
224 constexpr size_t height = 100;
227 ON_CALL(epoxy, glGetString(GL_VENDOR))
229 ::testing::Return(
reinterpret_cast<const GLubyte*
>(
"Intel")));
233 .WillRepeatedly(::testing::Return(
false));
235 ::testing::StrEq(
"GL_EXT_framebuffer_blit")))
236 .WillRepeatedly(::testing::Return(
true));
238 EXPECT_CALL(epoxy, glBlitFramebuffer);
244 .open_gl = {.framebuffer = {.user_data =
framebuffer}}};
246 .backing_store = &backing_store,
255 int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
width);
256 g_autofree
unsigned char* image_data =
257 static_cast<unsigned char*
>(malloc(
height * stride));
258 cairo_surface_t*
surface = cairo_image_surface_create_for_data(
259 image_data, CAIRO_FORMAT_ARGB32,
width,
height, stride);
260 cairo_t* cr = cairo_create(
surface);
262 cairo_surface_destroy(
surface);
267 constexpr size_t width = 100;
268 constexpr size_t height = 100;
271 ON_CALL(epoxy, glGetString(GL_VENDOR))
273 ::testing::Return(
reinterpret_cast<const GLubyte*
>(
"Intel")));
281 .open_gl = {.framebuffer = {.user_data =
framebuffer}}};
283 .backing_store = &backing_store,
292 int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
width);
293 g_autofree
unsigned char* image_data =
294 static_cast<unsigned char*
>(malloc(
height * stride));
295 cairo_surface_t*
surface = cairo_image_surface_create_for_data(
296 image_data, CAIRO_FORMAT_ARGB32,
width,
height, stride);
297 cairo_t* cr = cairo_create(
surface);
299 cairo_surface_destroy(
surface);
304 constexpr size_t width = 100;
305 constexpr size_t height = 100;
309 ON_CALL(epoxy, glGetString(GL_VENDOR))
311 ::testing::Return(
reinterpret_cast<const GLubyte*
>(
"NVIDIA")));
319 .open_gl = {.framebuffer = {.user_data =
framebuffer}}};
321 .backing_store = &backing_store,
330 int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
width);
331 g_autofree
unsigned char* image_data =
332 static_cast<unsigned char*
>(malloc(
height * stride));
333 cairo_surface_t*
surface = cairo_image_surface_create_for_data(
334 image_data, CAIRO_FORMAT_ARGB32,
width,
height, stride);
335 cairo_t* cr = cairo_create(
surface);
337 cairo_surface_destroy(
surface);
343 constexpr size_t width = 100;
344 constexpr size_t height = 100;
349 .open_gl = {.framebuffer = {.user_data =
framebuffer}}};
351 .backing_store = &backing_store,
362 .WillRepeatedly(::testing::Return(200));
364 .WillRepeatedly(::testing::Return(200));
370 int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, 200);
371 g_autofree
unsigned char* image_data =
372 static_cast<unsigned char*
>(g_malloc(200 * stride));
373 cairo_surface_t*
surface = cairo_image_surface_create_for_data(
374 image_data, CAIRO_FORMAT_ARGB32, 200, 200, stride);
375 cairo_t* cr = cairo_create(
surface);
380 cairo_surface_destroy(
surface);
FlOpenGLManager * opengl_manager
FlCompositorOpenGL * compositor
~FlCompositorOpenGLTest()
FlMockRenderable * renderable
FlTaskRunner * task_runner
::testing::NiceMock< flutter::testing::MockEpoxy > epoxy
@ kFlutterLayerContentTypeBackingStore
@ kFlutterBackingStoreTypeOpenGL
g_autoptr(FlEngine) engine
gboolean fl_compositor_render(FlCompositor *self, cairo_t *cr, GdkWindow *window, gboolean wait_for_frame)
void fl_compositor_get_frame_size(FlCompositor *self, size_t *width, size_t *height)
gboolean fl_compositor_present_layers(FlCompositor *self, const FlutterLayer **layers, size_t layers_count)
FlFramebuffer * framebuffer
glBindTexture(GL_TEXTURE_2D, texture_id)
FlCompositorOpenGL * fl_compositor_opengl_new(FlTaskRunner *task_runner, FlOpenGLManager *opengl_manager, gboolean shareable)
TEST_F(FlCompositorOpenGLTest, Render)
const FlutterLayer ** layers
void fl_engine_set_implicit_view(FlEngine *self, FlRenderable *renderable)
FlFramebuffer * fl_framebuffer_new(GLint format, size_t width, size_t height, gboolean shareable)
FlOpenGLManager * fl_opengl_manager_new()
FlTaskRunner * fl_task_runner_new(FlEngine *engine)
bool epoxy_has_gl_extension(const char *extension)
bool epoxy_is_desktop_gl(void)
int epoxy_gl_version(void)
int gdk_window_get_width(GdkWindow *window)
int gdk_window_get_height(GdkWindow *window)
FlutterBackingStoreType type
Specifies the type of backing store.
FlutterLayerContentType type