forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 17
Texture api change #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bbrto21
merged 23 commits into
flutter-tizen:flutter-2.0.1-tizen
from
xiaowei-guan:flutter-2.0.1-tizen-texture-2
May 27, 2021
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
3b7f88c
Add platfrom surface buffer structor
xiaowei-guan f6d12da
Texture api change(draft)
xiaowei-guan 7874e37
Merge branch 'flutter-2.0.1-tizen' into flutter-2.0.1-tizen-texture-2
xiaowei-guan 3f7dabf
Revert code to original
xiaowei-guan 08aaed6
Support GPU buffer texture
xiaowei-guan f3bf70f
Change file permission
xiaowei-guan 4abc488
Add FlutterDesktopGpuBufferTextureConfig in FlutterDesktopTextureInfo.
xiaowei-guan 77442be
Add buffer parameter at Destruction callback
xiaowei-guan 4b8106c
Change class name ExternalTextureGL to ExternalTextureSurfaceGL
xiaowei-guan 18ab87f
Remove not used code
xiaowei-guan f792f4e
Fix wild pointer issue
xiaowei-guan 3576fd8
Convert unique_ptr to shared_ptr when create external texture
xiaowei-guan 624b0d7
Merge branch 'flutter-2.0.1-tizen' into flutter-2.0.1-tizen-texture-2
xiaowei-guan 0f5f923
Code format
xiaowei-guan 240302a
Fix arm64 build error
xiaowei-guan c6b1970
Remove not used file
xiaowei-guan 275201f
Remove unnecessary headers
xiaowei-guan 4a56f3a
Refactor based on comments
xiaowei-guan d662053
Refactor based on comments
xiaowei-guan b91ffe3
Fix code review issue
xiaowei-guan a7cda29
Fix code review issue
xiaowei-guan 4849389
Fix code review issue
xiaowei-guan 00afe06
Remove warning log
xiaowei-guan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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" | ||
xiaowei-guan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.