From 7391e42fe28411213d226366a16f4b5d6112d3e5 Mon Sep 17 00:00:00 2001 From: CloudWebRTC Date: Wed, 17 Jul 2019 01:51:30 +0800 Subject: [PATCH] Fix compilation errors for linux and clang/gn format. --- .../include/flutter/plugin_registrar.h | 4 +-- .../testing/stub_flutter_api.cc | 36 +++++++++---------- .../cpp/public/flutter_texture_registrar.h | 9 +++-- shell/platform/glfw/BUILD.gn | 11 +++--- shell/platform/glfw/external_texture_gl.cc | 15 +++++--- shell/platform/glfw/external_texture_gl.h | 10 +++--- shell/platform/glfw/flutter_glfw.cc | 13 ++++--- 7 files changed, 55 insertions(+), 43 deletions(-) diff --git a/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registrar.h b/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registrar.h index 2262c07a64c60..1e9713764de84 100644 --- a/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registrar.h +++ b/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registrar.h @@ -41,7 +41,7 @@ class PluginRegistrar { // // This pointer will remain valid for the lifetime of this instance. BinaryMessenger* messenger() { return messenger_.get(); } - + TextureRegistrar* textures() { return textures_.get(); } // Takes ownership of |plugin|. @@ -62,7 +62,7 @@ class PluginRegistrar { FlutterDesktopPluginRegistrarRef registrar_; std::unique_ptr messenger_; - + std::unique_ptr textures_; // Plugins registered for ownership. diff --git a/shell/platform/common/cpp/client_wrapper/testing/stub_flutter_api.cc b/shell/platform/common/cpp/client_wrapper/testing/stub_flutter_api.cc index a48858fc5b299..fba049058ab0c 100644 --- a/shell/platform/common/cpp/client_wrapper/testing/stub_flutter_api.cc +++ b/shell/platform/common/cpp/client_wrapper/testing/stub_flutter_api.cc @@ -47,26 +47,26 @@ FlutterDesktopMessengerRef FlutterDesktopRegistrarGetMessenger( FlutterDesktopTextureRegistrarRef FlutterDesktopGetTextureRegistrar( FlutterDesktopPluginRegistrarRef registrar) { return reinterpret_cast(1); - } +} int64_t FlutterDesktopRegisterExternalTexture( - FlutterDesktopTextureRegistrarRef texture_registrar, - FlutterTexutreCallback texture_callback, - void* user_data) { - return -1; - } - - bool FlutterDesktopUnregisterExternalTexture( - FlutterDesktopTextureRegistrarRef texture_registrar, - int64_t texture_id) { - return false; - } - - bool FlutterDesktopMarkExternalTextureFrameAvailable( - FlutterDesktopTextureRegistrarRef texture_registrar, - int64_t texture_id) { - return false; - } + FlutterDesktopTextureRegistrarRef texture_registrar, + FlutterTexutreCallback texture_callback, + void* user_data) { + return -1; +} + +bool FlutterDesktopUnregisterExternalTexture( + FlutterDesktopTextureRegistrarRef texture_registrar, + int64_t texture_id) { + return false; +} + +bool FlutterDesktopMarkExternalTextureFrameAvailable( + FlutterDesktopTextureRegistrarRef texture_registrar, + int64_t texture_id) { + return false; +} void FlutterDesktopRegistrarEnableInputBlocking( FlutterDesktopPluginRegistrarRef registrar, diff --git a/shell/platform/common/cpp/public/flutter_texture_registrar.h b/shell/platform/common/cpp/public/flutter_texture_registrar.h index 3bf7627c2a897..3d3e1c13b3f99 100644 --- a/shell/platform/common/cpp/public/flutter_texture_registrar.h +++ b/shell/platform/common/cpp/public/flutter_texture_registrar.h @@ -37,15 +37,18 @@ typedef const PixelBuffer* (*FlutterTexutreCallback)(size_t width, // function to copy the pixel buffer from the plugin caller. FLUTTER_EXPORT int64_t FlutterDesktopRegisterExternalTexture( FlutterDesktopTextureRegistrarRef texture_registrar, - FlutterTexutreCallback texture_callback, void* user_data); + FlutterTexutreCallback texture_callback, + void* user_data); // Unregister an existing texture from the flutter engine for a |texture_id|. FLUTTER_EXPORT bool FlutterDesktopUnregisterExternalTexture( - FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id); + FlutterDesktopTextureRegistrarRef texture_registrar, + int64_t texture_id); // Mark that a new texture frame is available for a given |texture_id|. FLUTTER_EXPORT bool FlutterDesktopMarkExternalTextureFrameAvailable( - FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id); + FlutterDesktopTextureRegistrarRef texture_registrar, + int64_t texture_id); #if defined(__cplusplus) } // extern "C" diff --git a/shell/platform/glfw/BUILD.gn b/shell/platform/glfw/BUILD.gn index 04e028e045339..895a767c8e428 100644 --- a/shell/platform/glfw/BUILD.gn +++ b/shell/platform/glfw/BUILD.gn @@ -32,8 +32,8 @@ source_set("flutter_glfw_headers") { source_set("flutter_glfw") { sources = [ - "external_texture_gl.h", "external_texture_gl.cc", + "external_texture_gl.h", "flutter_glfw.cc", "glfw_event_loop.cc", "glfw_event_loop.h", @@ -46,7 +46,10 @@ source_set("flutter_glfw") { "text_input_plugin.h", ] - defines = [ "USE_RAPID_JSON", "GLFW_INCLUDE_NONE" ] + defines = [ + "USE_RAPID_JSON", + "GLFW_INCLUDE_NONE", + ] configs += [ "$flutter_root/shell/platform/common/cpp:desktop_library_implementation", @@ -62,8 +65,8 @@ source_set("flutter_glfw") { "//third_party/rapidjson", ] if (is_win) { - deps += [ "//build/secondary/third_party/glfw:glad" ] - }else if (is_linux) { + deps += [ "//build/secondary/third_party/glfw:glad" ] + } else if (is_linux) { libs = [ "GL" ] configs += [ diff --git a/shell/platform/glfw/external_texture_gl.cc b/shell/platform/glfw/external_texture_gl.cc index 0125131109d2b..2dfc83d883cf0 100644 --- a/shell/platform/glfw/external_texture_gl.cc +++ b/shell/platform/glfw/external_texture_gl.cc @@ -14,15 +14,18 @@ ExternalTextureGL::ExternalTextureGL(FlutterTexutreCallback texture_callback, : texture_callback_(texture_callback), user_data_(user_data) {} ExternalTextureGL::~ExternalTextureGL() { - if (gl_texture_ != 0) glDeleteTextures(1, &gl_texture_); + if (gl_texture_ != 0) + glDeleteTextures(1, &gl_texture_); } - int64_t ExternalTextureGL::texutre_id() { +int64_t ExternalTextureGL::texutre_id() { return reinterpret_cast(this); } bool ExternalTextureGL::PopulateTextureWithIdentifier( - size_t width, size_t height, FlutterOpenGLTexture* texture) { + size_t width, + size_t height, + FlutterOpenGLTexture* texture) { // Confirm that the current window context is available. if (!window_) { window_ = glfwGetCurrentContext(); @@ -33,12 +36,14 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier( } } - if (!window_) return false; + if (!window_) + return false; const PixelBuffer* pixel_buffer = texture_callback_(width, height, user_data_); - if (!pixel_buffer || !pixel_buffer->buffer) return false; + if (!pixel_buffer || !pixel_buffer->buffer) + return false; if (gl_texture_ == 0) { glGenTextures(1, &gl_texture_); diff --git a/shell/platform/glfw/external_texture_gl.h b/shell/platform/glfw/external_texture_gl.h index e6f0c0cb15e7d..f1f4ab588fb12 100644 --- a/shell/platform/glfw/external_texture_gl.h +++ b/shell/platform/glfw/external_texture_gl.h @@ -5,15 +5,13 @@ #ifndef FLUTTER_SHELL_PLATFORM_GLFW_EXTERNAL_TEXTURE_GL_H_ #define FLUTTER_SHELL_PLATFORM_GLFW_EXTERNAL_TEXTURE_GL_H_ -#include "flutter/shell/platform/embedder/embedder.h" - #include -#include #include +#include -#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/texture_registrar.h" -#include "flutter/shell/platform/glfw/public/flutter_glfw.h" +#include "flutter/shell/platform/common/cpp/public/flutter_texture_registrar.h" +#include "flutter/shell/platform/embedder/embedder.h" namespace flutter { @@ -23,7 +21,7 @@ class ExternalTextureGL { ExternalTextureGL(FlutterTexutreCallback texture_callback, void* user_data); virtual ~ExternalTextureGL(); - + int64_t texutre_id(); bool PopulateTextureWithIdentifier(size_t width, diff --git a/shell/platform/glfw/flutter_glfw.cc b/shell/platform/glfw/flutter_glfw.cc index 09bb3f1ff708f..98d35fa8fdbf6 100644 --- a/shell/platform/glfw/flutter_glfw.cc +++ b/shell/platform/glfw/flutter_glfw.cc @@ -500,8 +500,8 @@ static bool OnAcquireExternalTexture(void* user_data, FlutterOpenGLTexture* texture) { GLFWwindow* window = reinterpret_cast(user_data); auto state = GetSavedWindowState(window); - return state->plugin_registrar->texture_registrar->textures[texture_id]->PopulateTextureWithIdentifier( - width, height, texture); + return state->plugin_registrar->texture_registrar->textures[texture_id] + ->PopulateTextureWithIdentifier(width, height, texture); } static void GLFWErrorCallback(int error_code, const char* description) { @@ -876,7 +876,8 @@ void FlutterDesktopMessengerSetCallback(FlutterDesktopMessengerRef messenger, int64_t FlutterDesktopRegisterExternalTexture( FlutterDesktopTextureRegistrarRef texture_registrar, - FlutterTexutreCallback texture_callback, void* user_data) { + FlutterTexutreCallback texture_callback, + void* user_data) { std::unique_ptr texture_gl( new flutter::ExternalTextureGL(texture_callback, user_data)); int64_t texture_id = texture_gl->texutre_id(); @@ -889,7 +890,8 @@ int64_t FlutterDesktopRegisterExternalTexture( } bool FlutterDesktopUnregisterExternalTexture( - FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id) { + FlutterDesktopTextureRegistrarRef texture_registrar, + int64_t texture_id) { auto it = texture_registrar->textures.find(texture_id); if (it != texture_registrar->textures.end()) texture_registrar->textures.erase(it); @@ -898,7 +900,8 @@ bool FlutterDesktopUnregisterExternalTexture( } bool FlutterDesktopMarkExternalTextureFrameAvailable( - FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id) { + FlutterDesktopTextureRegistrarRef texture_registrar, + int64_t texture_id) { return (FlutterEngineMarkExternalTextureFrameAvailable( texture_registrar->engine, texture_id) == kSuccess); }