Skip to content

Commit

Permalink
Fix compilation errors for linux and clang/gn format.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Jul 16, 2019
1 parent d1266a8 commit 7391e42
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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|.
Expand All @@ -62,7 +62,7 @@ class PluginRegistrar {
FlutterDesktopPluginRegistrarRef registrar_;

std::unique_ptr<BinaryMessenger> messenger_;

std::unique_ptr<TextureRegistrar> textures_;

// Plugins registered for ownership.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,26 @@ FlutterDesktopMessengerRef FlutterDesktopRegistrarGetMessenger(
FlutterDesktopTextureRegistrarRef FlutterDesktopGetTextureRegistrar(
FlutterDesktopPluginRegistrarRef registrar) {
return reinterpret_cast<FlutterDesktopTextureRegistrarRef>(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,
Expand Down
9 changes: 6 additions & 3 deletions shell/platform/common/cpp/public/flutter_texture_registrar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 7 additions & 4 deletions shell/platform/glfw/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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 += [
Expand Down
15 changes: 10 additions & 5 deletions shell/platform/glfw/external_texture_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>(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();
Expand All @@ -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_);
Expand Down
10 changes: 4 additions & 6 deletions shell/platform/glfw/external_texture_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdint.h>

#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glad/glad.h>

#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 {

Expand All @@ -23,7 +21,7 @@ class ExternalTextureGL {
ExternalTextureGL(FlutterTexutreCallback texture_callback, void* user_data);

virtual ~ExternalTextureGL();

int64_t texutre_id();

bool PopulateTextureWithIdentifier(size_t width,
Expand Down
13 changes: 8 additions & 5 deletions shell/platform/glfw/flutter_glfw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ static bool OnAcquireExternalTexture(void* user_data,
FlutterOpenGLTexture* texture) {
GLFWwindow* window = reinterpret_cast<GLFWwindow*>(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) {
Expand Down Expand Up @@ -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<flutter::ExternalTextureGL> texture_gl(
new flutter::ExternalTextureGL(texture_callback, user_data));
int64_t texture_id = texture_gl->texutre_id();
Expand All @@ -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);
Expand All @@ -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);
}

0 comments on commit 7391e42

Please sign in to comment.