Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions shell/platform/tizen/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ template("embedder") {
"channels/settings_channel.cc",
"channels/text_input_channel.cc",
"channels/window_channel.cc",
"external_texture_pixel_evas_gl.cc",
"external_texture_surface_evas_gl.cc",
"flutter_project_bundle.cc",
"flutter_tizen.cc",
Expand Down Expand Up @@ -160,10 +161,7 @@ template("embedder") {
"evas",
"feedback",
"tbm",
"tdm-client",
"wayland-client",
"EGL",
"GLESv2",
]

if (target_name == "flutter_tizen_common") {
Expand All @@ -189,6 +187,7 @@ template("embedder") {

if (target_name != "flutter_tizen_wearable") {
sources += [
"external_texture_pixel_egl.cc",
"external_texture_surface_egl.cc",
"tizen_renderer_egl.cc",
"tizen_vsync_waiter.cc",
Expand All @@ -197,7 +196,10 @@ template("embedder") {

libs += [
"ecore_wl2",
"tdm-client",
"tizen-extension-client",
"EGL",
"GLESv2",
]
}

Expand Down
70 changes: 70 additions & 0 deletions shell/platform/tizen/external_texture_pixel_egl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "external_texture_pixel_egl.h"

#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES3/gl32.h>

namespace flutter {

bool ExternalTexturePixelEGL::PopulateTexture(
size_t width,
size_t height,
FlutterOpenGLTexture* opengl_texture) {
if (!CopyPixelBuffer(width, height)) {
return false;
}

// Populate the texture object used by the engine.
opengl_texture->target = GL_TEXTURE_2D;
opengl_texture->name = state_->gl_texture;
opengl_texture->format = GL_RGBA8;
opengl_texture->destruction_callback = nullptr;
opengl_texture->user_data = nullptr;
opengl_texture->width = width;
opengl_texture->height = height;
return true;
}

ExternalTexturePixelEGL::ExternalTexturePixelEGL(
FlutterDesktopPixelBufferTextureCallback texture_callback,
void* user_data)
: ExternalTexture(),
texture_callback_(texture_callback),
user_data_(user_data) {}

bool ExternalTexturePixelEGL::CopyPixelBuffer(size_t& width, size_t& height) {
if (!texture_callback_) {
return false;
}

const FlutterDesktopPixelBuffer* pixel_buffer =
texture_callback_(width, height, user_data_);

if (!pixel_buffer || !pixel_buffer->buffer) {
return false;
}

width = pixel_buffer->width;
height = pixel_buffer->height;

if (state_->gl_texture == 0) {
glGenTextures(1, static_cast<GLuint*>(&state_->gl_texture));
glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(state_->gl_texture));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} else {
glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(state_->gl_texture));
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixel_buffer->width,
pixel_buffer->height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
pixel_buffer->buffer);
return true;
}

} // namespace flutter
35 changes: 35 additions & 0 deletions shell/platform/tizen/external_texture_pixel_egl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef EMBEDDER_EXTERNAL_TEXTURE_PIXEL_EGL_H
#define EMBEDDER_EXTERNAL_TEXTURE_PIXEL_EGL_H

#include "flutter/shell/platform/common/public/flutter_texture_registrar.h"
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/tizen/external_texture.h"

namespace flutter {

class ExternalTexturePixelEGL : public ExternalTexture {
public:
ExternalTexturePixelEGL(
FlutterDesktopPixelBufferTextureCallback texture_callback,
void* user_data);

~ExternalTexturePixelEGL() = default;

bool PopulateTexture(size_t width,
size_t height,
FlutterOpenGLTexture* opengl_texture) override;

bool CopyPixelBuffer(size_t& width, size_t& height);

private:
FlutterDesktopPixelBufferTextureCallback texture_callback_ = nullptr;
void* user_data_ = nullptr;
};

} // namespace flutter

#endif // EMBEDDER_EXTERNAL_TEXTURE_PIXEL_EGL_H
71 changes: 71 additions & 0 deletions shell/platform/tizen/external_texture_pixel_evas_gl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "external_texture_pixel_evas_gl.h"

#include "tizen_evas_gl_helper.h"
extern Evas_GL* g_evas_gl;
EVAS_GL_GLOBAL_GLES2_DECLARE();

namespace flutter {

bool ExternalTexturePixelEvasGL::PopulateTexture(
size_t width,
size_t height,
FlutterOpenGLTexture* opengl_texture) {
if (!CopyPixelBuffer(width, height)) {
return false;
}

// Populate the texture object used by the engine.
opengl_texture->target = GL_TEXTURE_2D;
opengl_texture->name = state_->gl_texture;
opengl_texture->format = GL_RGBA8;
opengl_texture->destruction_callback = nullptr;
opengl_texture->user_data = nullptr;
opengl_texture->width = width;
opengl_texture->height = height;
return true;
}

ExternalTexturePixelEvasGL::ExternalTexturePixelEvasGL(
FlutterDesktopPixelBufferTextureCallback texture_callback,
void* user_data)
: ExternalTexture(),
texture_callback_(texture_callback),
user_data_(user_data) {}

bool ExternalTexturePixelEvasGL::CopyPixelBuffer(size_t& width,
size_t& height) {
if (!texture_callback_) {
return false;
}

const FlutterDesktopPixelBuffer* pixel_buffer =
texture_callback_(width, height, user_data_);

if (!pixel_buffer || !pixel_buffer->buffer) {
return false;
}

width = pixel_buffer->width;
height = pixel_buffer->height;

if (state_->gl_texture == 0) {
glGenTextures(1, static_cast<GLuint*>(&state_->gl_texture));
glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(state_->gl_texture));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} else {
glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(state_->gl_texture));
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixel_buffer->width,
pixel_buffer->height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
pixel_buffer->buffer);
return true;
}

} // namespace flutter
35 changes: 35 additions & 0 deletions shell/platform/tizen/external_texture_pixel_evas_gl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef EMBEDDER_EXTERNAL_TEXTURE_PIXEL_EVAS_GL_H
#define EMBEDDER_EXTERNAL_TEXTURE_PIXEL_EVAS_GL_H

#include "flutter/shell/platform/common/public/flutter_texture_registrar.h"
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/tizen/external_texture.h"

namespace flutter {

class ExternalTexturePixelEvasGL : public ExternalTexture {
public:
ExternalTexturePixelEvasGL(
FlutterDesktopPixelBufferTextureCallback texture_callback,
void* user_data);

~ExternalTexturePixelEvasGL() = default;

bool PopulateTexture(size_t width,
size_t height,
FlutterOpenGLTexture* opengl_texture) override;

bool CopyPixelBuffer(size_t& width, size_t& height);

private:
FlutterDesktopPixelBufferTextureCallback texture_callback_ = nullptr;
void* user_data_ = nullptr;
};

} // namespace flutter

#endif // EMBEDDER_EXTERNAL_TEXTURE_PIXEL_EVAS_GL_H
16 changes: 14 additions & 2 deletions shell/platform/tizen/flutter_tizen_texture_registrar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
#include <mutex>

#ifndef WEARABLE_PROFILE
#include "flutter/shell/platform/tizen/external_texture_pixel_egl.h"
#include "flutter/shell/platform/tizen/external_texture_surface_egl.h"
#endif
#include "flutter/shell/platform/tizen/external_texture_pixel_evas_gl.h"
#include "flutter/shell/platform/tizen/external_texture_surface_evas_gl.h"
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
#include "flutter/shell/platform/tizen/logger.h"
Expand Down Expand Up @@ -102,8 +104,18 @@ FlutterTizenTextureRegistrar::CreateExternalTexture(
FlutterDesktopRendererType renderer_type) {
switch (texture_info->type) {
case kFlutterDesktopPixelBufferTexture:
FT_UNIMPLEMENTED();
if (renderer_type == FlutterDesktopRendererType::kEvasGL) {
return std::make_unique<ExternalTexturePixelEvasGL>(
texture_info->pixel_buffer_config.callback,
texture_info->pixel_buffer_config.user_data);
}
#ifndef WEARABLE_PROFILE
return std::make_unique<ExternalTexturePixelEGL>(
texture_info->pixel_buffer_config.callback,
texture_info->pixel_buffer_config.user_data);
#else
return nullptr;
#endif
case kFlutterDesktopGpuBufferTexture:
ExternalTextureExtensionType gl_extension =
ExternalTextureExtensionType::kNone;
Expand All @@ -115,7 +127,7 @@ FlutterTizenTextureRegistrar::CreateExternalTexture(
"EGL_EXT_image_dma_buf_import")) {
gl_extension = ExternalTextureExtensionType::kDmaBuffer;
}
if (FlutterDesktopRendererType::kEvasGL == renderer_type) {
if (renderer_type == FlutterDesktopRendererType::kEvasGL) {
return std::make_unique<ExternalTextureSurfaceEvasGL>(
gl_extension, texture_info->gpu_buffer_config.callback,
texture_info->gpu_buffer_config.user_data);
Expand Down