Flutter Engine
mock_renderer.cc
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 #include "flutter/shell/platform/linux/testing/mock_renderer.h"
6 
8  FlRenderer parent_instance;
9 };
10 
11 G_DEFINE_TYPE(FlMockRenderer, fl_mock_renderer, fl_renderer_get_type())
12 
13 // Implements FlRenderer::create_display.
14 static EGLDisplay fl_mock_renderer_create_display(FlRenderer* renderer) {
15  return eglGetDisplay(EGL_DEFAULT_DISPLAY);
16 }
17 
18 // Implements FlRenderer::create_surfaces.
19 static gboolean fl_mock_renderer_create_surfaces(FlRenderer* renderer,
20  GtkWidget* widget,
21  EGLDisplay display,
22  EGLConfig config,
23  EGLSurface* visible,
24  EGLSurface* resource,
25  GError** error) {
26  *visible = eglCreateWindowSurface(display, config, 0, nullptr);
27  const EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE};
28  *resource = eglCreatePbufferSurface(display, config, attribs);
29  return TRUE;
30 }
31 
32 static void fl_mock_renderer_class_init(FlMockRendererClass* klass) {
33  FL_RENDERER_CLASS(klass)->create_display = fl_mock_renderer_create_display;
34  FL_RENDERER_CLASS(klass)->create_surfaces = fl_mock_renderer_create_surfaces;
35 }
36 
37 static void fl_mock_renderer_init(FlMockRenderer* self) {}
38 
39 // Creates a stub renderer
40 FlMockRenderer* fl_mock_renderer_new() {
41  return FL_MOCK_RENDERER(g_object_new(fl_mock_renderer_get_type(), nullptr));
42 }
FlMockRenderer * fl_mock_renderer_new()
FlMethodResponse GError ** error
static void fl_mock_renderer_class_init(FlMockRendererClass *klass)
EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id)
Definition: mock_egl.cc:248
FlRenderer parent_instance
Definition: mock_renderer.cc:8
EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
Definition: mock_egl.cc:142
static void fl_mock_renderer_init(FlMockRenderer *self)
static gboolean fl_mock_renderer_create_surfaces(FlRenderer *renderer, GtkWidget *widget, EGLDisplay display, EGLConfig config, EGLSurface *visible, EGLSurface *resource, GError **error)
return TRUE
Definition: fl_view.cc:107
G_DEFINE_TYPE(FlBasicMessageChannelResponseHandle, fl_basic_message_channel_response_handle, G_TYPE_OBJECT) static void fl_basic_message_channel_response_handle_dispose(GObject *object)
static EGLDisplay fl_mock_renderer_create_display(FlRenderer *renderer)
EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
Definition: mock_egl.cc:132