Skip to content

Commit

Permalink
GLFW example with dirty region management (flutter#35057)
Browse files Browse the repository at this point in the history
* Update the GLFW example callbacks.

* Update the dart example.

* Update CMakeLists

* Update library dependencies in the BUILD file.

* Documenting.

* Formatting.

* Update the callback name.

* Move glfw_drm example to a new folder.

* Create new example folder for drm_embedder.

* Add the flutter spinkit dependency

* Update BUILD files.

* Do not compile glfw_drm example if running it on mac.

* Update the executable name for the glfw_drm example.

* Avoid looking for the surface and display every time since they are always the same.

* Formatting.

* GN formatting.

* Update the way the user malloc's the existing damage

* Update comment

* Update example and add gitignore.

Co-authored-by: Bernardo Eilert Trevisan <[email protected]>
  • Loading branch information
betrevisan and Bernardo Eilert Trevisan authored Aug 15, 2022
1 parent 198b005 commit 33fccf5
Show file tree
Hide file tree
Showing 8 changed files with 544 additions and 0 deletions.
4 changes: 4 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ group("flutter") {
"//flutter/examples/glfw",
"//flutter/examples/vulkan_glfw",
]

if (!is_mac) {
public_deps += [ "//flutter/examples/glfw_drm" ]
}
}

# If enbaled, compile the SDK / snapshot.
Expand Down
1 change: 1 addition & 0 deletions examples/glfw_drm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
debug/
20 changes: 20 additions & 0 deletions examples/glfw_drm/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//flutter/examples/examples.gni")

if (build_embedder_examples) {
executable("glfw_drm") {
output_name = "embedder_example_drm"

sources = [ "FlutterEmbedderGLFW.cc" ]

deps = [
"//flutter/shell/platform/embedder:embedder",
"//third_party/glfw",
]

libs = [ "EGL" ]
}
}
35 changes: 35 additions & 0 deletions examples/glfw_drm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.15)
project(FlutterEmbedderGLFW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )

add_executable(flutter_glfw FlutterEmbedderGLFW.cc)

############################################################
# GLFW
############################################################
option(GLFW_BUILD_EXAMPLES "" OFF)
option(GLFW_BUILD_TESTS "" OFF)
option(GLFW_BUILD_DOCS "" OFF)
option(GLFW_INSTALL "" OFF)
find_package(OpenGL REQUIRED COMPONENTS EGL)
include_directories(${OPENGL_INCLUDE_DIRS})
add_subdirectory(${CMAKE_SOURCE_DIR}/../../../third_party/glfw glfw)
target_link_libraries(flutter_glfw glfw OpenGL::EGL)
include_directories(${CMAKE_SOURCE_DIR}/../../../third_party/glfw/include)

############################################################
# Flutter Engine
############################################################
# This is assuming you've built a local version of the Flutter Engine. If you
# downloaded yours is from the internet you'll have to change this.
include_directories(${CMAKE_SOURCE_DIR}/../../shell/platform/embedder)
find_library(FLUTTER_LIB flutter_engine PATHS ${CMAKE_SOURCE_DIR}/../../../out/host_debug_unopt)
target_link_libraries(flutter_glfw ${FLUTTER_LIB})

# Copy the flutter library here since the shared library
# name is `./libflutter_engine.dylib`.
add_custom_command(
TARGET flutter_glfw POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${FLUTTER_LIB}
${CMAKE_CURRENT_BINARY_DIR})
Loading

0 comments on commit 33fccf5

Please sign in to comment.