Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3b7f88c
Add platfrom surface buffer structor
xiaowei-guan May 8, 2021
f6d12da
Texture api change(draft)
xiaowei-guan May 11, 2021
7874e37
Merge branch 'flutter-2.0.1-tizen' into flutter-2.0.1-tizen-texture-2
xiaowei-guan May 11, 2021
3f7dabf
Revert code to original
xiaowei-guan May 11, 2021
08aaed6
Support GPU buffer texture
xiaowei-guan May 13, 2021
f3bf70f
Change file permission
xiaowei-guan May 13, 2021
4abc488
Add FlutterDesktopGpuBufferTextureConfig in FlutterDesktopTextureInfo.
xiaowei-guan May 14, 2021
77442be
Add buffer parameter at Destruction callback
xiaowei-guan May 18, 2021
4b8106c
Change class name ExternalTextureGL to ExternalTextureSurfaceGL
xiaowei-guan May 19, 2021
18ab87f
Remove not used code
xiaowei-guan May 20, 2021
f792f4e
Fix wild pointer issue
xiaowei-guan May 21, 2021
3576fd8
Convert unique_ptr to shared_ptr when create external texture
xiaowei-guan May 24, 2021
624b0d7
Merge branch 'flutter-2.0.1-tizen' into flutter-2.0.1-tizen-texture-2
xiaowei-guan May 24, 2021
0f5f923
Code format
xiaowei-guan May 24, 2021
240302a
Fix arm64 build error
xiaowei-guan May 24, 2021
c6b1970
Remove not used file
xiaowei-guan May 24, 2021
275201f
Remove unnecessary headers
xiaowei-guan May 25, 2021
4a56f3a
Refactor based on comments
xiaowei-guan May 25, 2021
d662053
Refactor based on comments
xiaowei-guan May 25, 2021
b91ffe3
Fix code review issue
xiaowei-guan May 26, 2021
a7cda29
Fix code review issue
xiaowei-guan May 26, 2021
4849389
Fix code review issue
xiaowei-guan May 26, 2021
00afe06
Remove warning log
xiaowei-guan May 27, 2021
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
Next Next commit
Add platfrom surface buffer structor
  • Loading branch information
xiaowei-guan committed May 8, 2021
commit 3b7f88caea3e2768ee950bc1c5ff4cb816b9eff9
21 changes: 17 additions & 4 deletions shell/platform/common/cpp/client_wrapper/core_implementations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ namespace {
// interface provided by the C API and the std::function-based message handler
// interface of BinaryMessenger.
void ForwardToHandler(FlutterDesktopMessengerRef messenger,
const FlutterDesktopMessage* message,
void* user_data) {
const FlutterDesktopMessage* message, void* user_data) {
auto* response_handle = message->response_handle;
BinaryReply reply_handler = [messenger, response_handle](
const uint8_t* reply,
Expand Down Expand Up @@ -67,8 +66,7 @@ BinaryMessengerImpl::BinaryMessengerImpl(
BinaryMessengerImpl::~BinaryMessengerImpl() = default;

void BinaryMessengerImpl::Send(const std::string& channel,
const uint8_t* message,
size_t message_size,
const uint8_t* message, size_t message_size,
BinaryReply reply) const {
if (reply == nullptr) {
FlutterDesktopMessengerSend(messenger_, channel.c_str(), message,
Expand Down Expand Up @@ -169,6 +167,21 @@ int64_t TextureRegistrarImpl::RegisterTexture(TextureVariant* texture) {
return buffer;
};

int64_t texture_id = FlutterDesktopTextureRegistrarRegisterExternalTexture(
texture_registrar_ref_, &info);
return texture_id;
} else if (auto gpu_buffer_texture = std::get_if<GpuBufferTexture>(texture)) {
FlutterDesktopTextureInfo info = {};
info.type = kFlutterDesktopGpuBufferTexture;
info.pixel_buffer_config.user_data = gpu_buffer_texture;
info.pixel_buffer_config.gbCallback =
[](size_t width, size_t height,
void* user_data) -> const FlutterDesktopGpuBuffer* {
auto texture = static_cast<GpuBufferTexture*>(user_data);
auto buffer = texture->CopyGpuBuffer(width, height);
return buffer;
};

int64_t texture_id = FlutterDesktopTextureRegistrarRegisterExternalTexture(
texture_registrar_ref_, &info);
return texture_id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,39 @@ class PixelBufferTexture {
const CopyBufferCallback copy_buffer_callback_;
};

// A pixel buffer texture.
class GpuBufferTexture {
public:
// A callback used for retrieving pixel buffers.
typedef std::function<const FlutterDesktopGpuBuffer*(size_t width,
size_t height)>
CopyBufferCallback;

// Creates a pixel buffer texture that uses the provided |copy_buffer_cb| to
// retrieve the buffer.
// As the callback is usually invoked from the render thread, the callee must
// take care of proper synchronization. It also needs to be ensured that the
// returned buffer isn't released prior to unregistering this texture.
GpuBufferTexture(CopyBufferCallback copy_buffer_callback)
: copy_buffer_callback_(copy_buffer_callback) {}

// Returns the callback-provided FlutterDesktopPixelBuffer that contains the
// actual pixel data. The intended surface size is specified by |width| and
// |height|.
const FlutterDesktopGpuBuffer* CopyGpuBuffer(size_t width,
size_t height) const {
return copy_buffer_callback_(width, height);
}

private:
const CopyBufferCallback copy_buffer_callback_;
};


// The available texture variants.
// Only PixelBufferTexture is currently implemented.
// Other variants are expected to be added in the future.
typedef std::variant<PixelBufferTexture> TextureVariant;
typedef std::variant<PixelBufferTexture, GpuBufferTexture> TextureVariant;

// An object keeping track of external textures.
//
Expand Down
21 changes: 20 additions & 1 deletion shell/platform/common/cpp/public/flutter_texture_registrar.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ typedef struct FlutterDesktopTextureRegistrar*
// Additional types may be added in the future.
typedef enum {
// A Pixel buffer-based texture.
kFlutterDesktopPixelBufferTexture
kFlutterDesktopPixelBufferTexture,
kFlutterDesktopGpuBufferTexture
} FlutterDesktopTextureType;

// An image buffer object.
Expand All @@ -36,6 +37,17 @@ typedef struct {
size_t height;
} FlutterDesktopPixelBuffer;

// An image buffer object.
typedef struct {
// The pixel data buffer.
const void* buffer;
// Width of the pixel buffer.
size_t width;
// Height of the pixel buffer.
size_t height;
} FlutterDesktopGpuBuffer;


// The pixel buffer copy callback definition provided to
// the Flutter engine to copy the texture.
// It is invoked with the intended surface size specified by |width| and
Expand All @@ -49,11 +61,18 @@ typedef const FlutterDesktopPixelBuffer* (
*FlutterDesktopPixelBufferTextureCallback)(size_t width,
size_t height,
void* user_data);
typedef const FlutterDesktopGpuBuffer* (
*FlutterDesktopGpuBufferTextureCallback)(size_t width,
size_t height,
void* user_data);


// An object used to configure pixel buffer textures.
typedef struct {
// The callback used by the engine to copy the pixel buffer object.
FlutterDesktopPixelBufferTextureCallback callback;

FlutterDesktopGpuBufferTextureCallback gbCallback;
// Opaque data that will get passed to the provided |callback|.
void* user_data;
} FlutterDesktopPixelBufferTextureConfig;
Expand Down