forked from flutter-tizen/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Texture api change (flutter-tizen#86)
* Add platfrom surface buffer structor * Texture api change(draft) 1.Delete tizen texture api, use common api, add GpuBufferTexture for gpu buffer. 2.Delete ref/unref tbm_surface code in engine, add destructioncall for delete tbm_surface. 3.Support pixel buffer texture. * Revert code to original * Support GPU buffer texture 1.Implement GPU buffer texture. 2.Remove ref/unref tbm surface code. * Change file permission * Add FlutterDesktopGpuBufferTextureConfig in FlutterDesktopTextureInfo. * Add buffer parameter at Destruction callback * Change class name ExternalTextureGL to ExternalTextureSurfaceGL Class ExternamTextureSurfaceGL handle tbm surface texture render. * Remove not used code * Fix wild pointer issue If plugin call UnregisterTexture, then will remove external texture, But at this time, gpu render is not finish. when gpu render finished, tiggle destruction callback, need check whether external texture pointer is wild pointer * Convert unique_ptr to shared_ptr when create external texture * Code format * Fix arm64 build error * Remove not used file * Remove unnecessary headers * Refactor based on comments 1.Remove not used file. 2.Rename define of head file. 2.Rename of variable. * Refactor based on comments 1.Return nullptr for default case when create external texture. 2.Rename methode name from texture_registrar to GetTextureRegistrar. 3.Change OnCollectTextur to static function. * Fix code review issue 1.Use C++ style casts 2.Rename variable and function, make the code more friendly. 3.Add copyright info. * Fix code review issue 1.Rename static veriable(nextTextureId -> kNextTextureId) 2.Modify comment, make it more clear. 3.Rename function name(FlutterDesktopDestructionCallback) * Fix code review issue * Remove warning log This warning log shouldn't be displayed when launching a headless app.
- Loading branch information
1 parent
6a44376
commit 70887cf
Showing
16 changed files
with
528 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 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_H_ | ||
#define EMBEDDER_EXTERNAL_TEXTURE_H_ | ||
|
||
#include <atomic> | ||
#include <memory> | ||
#include "flutter/shell/platform/common/cpp/public/flutter_texture_registrar.h" | ||
#include "flutter/shell/platform/embedder/embedder.h" | ||
|
||
#ifdef TIZEN_RENDERER_EVAS_GL | ||
#undef EFL_BETA_API_SUPPORT | ||
#include <Evas_GL.h> | ||
#else | ||
#include <GLES2/gl2.h> | ||
#endif | ||
|
||
struct ExternalTextureGLState { | ||
GLuint gl_texture; | ||
}; | ||
|
||
static std::atomic_long next_texture_id = {1}; | ||
|
||
// An adaptation class of flutter engine and external texture interface. | ||
class ExternalTexture : public std::enable_shared_from_this<ExternalTexture> { | ||
public: | ||
ExternalTexture() | ||
: state_(std::make_unique<ExternalTextureGLState>()), | ||
texture_id_(next_texture_id++) {} | ||
virtual ~ExternalTexture() = default; | ||
|
||
/** | ||
* Returns the unique id for the ExternalTextureGL instance. | ||
*/ | ||
int64_t TextureId() { return (int64_t)texture_id_; } | ||
|
||
virtual bool PopulateTexture(size_t width, | ||
size_t height, | ||
FlutterOpenGLTexture* opengl_texture) = 0; | ||
virtual void OnDestruction(){}; | ||
|
||
protected: | ||
std::unique_ptr<ExternalTextureGLState> state_; | ||
const long texture_id_{0}; | ||
}; | ||
|
||
#endif // EMBEDDER_EXTERNAL_TEXTURE_H_ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "flutter/shell/platform/tizen/external_texture_pixel_gl.h" | ||
|
||
#ifdef TIZEN_RENDERER_EVAS_GL | ||
#undef EFL_BETA_API_SUPPORT | ||
#include <Evas_GL_GLES3_Helpers.h> | ||
extern Evas_GL* g_evas_gl; | ||
EVAS_GL_GLOBAL_GLES3_DECLARE(); | ||
#else | ||
#include <EGL/egl.h> | ||
#include <EGL/eglext.h> | ||
#include <GLES2/gl2ext.h> | ||
#include <GLES3/gl32.h> | ||
#endif | ||
|
||
bool ExternalTexturePixelGL::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; | ||
} | ||
|
||
ExternalTexturePixelGL::ExternalTexturePixelGL( | ||
FlutterDesktopPixelBufferTextureCallback texture_callback, | ||
void* user_data) | ||
: ExternalTexture(), | ||
texture_callback_(texture_callback), | ||
user_data_(user_data) {} | ||
|
||
bool ExternalTexturePixelGL::CopyPixelBuffer(size_t& width, size_t& height) { | ||
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, &state_->gl_texture); | ||
glBindTexture(GL_TEXTURE_2D, 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, 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// 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_GL_H | ||
#define EMBEDDER_EXTERNAL_TEXTURE_PIXEL_GL_H | ||
|
||
#include <memory> | ||
|
||
#include "flutter/shell/platform/common/cpp/public/flutter_texture_registrar.h" | ||
#include "flutter/shell/platform/embedder/embedder.h" | ||
#include "flutter/shell/platform/tizen/external_texture.h" | ||
|
||
// An adaptation class of flutter engine and external texture interface. | ||
class ExternalTexturePixelGL : public ExternalTexture { | ||
public: | ||
ExternalTexturePixelGL( | ||
FlutterDesktopPixelBufferTextureCallback texture_callback, | ||
void* user_data); | ||
|
||
~ExternalTexturePixelGL() = 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; | ||
}; | ||
|
||
#endif // EMBEDDER_EXTERNAL_TEXTURE_PIXEL_GL_H |
Oops, something went wrong.