Skip to content
Open
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
39 changes: 38 additions & 1 deletion flutter/shell/platform/embedder/embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,9 @@ typedef void* FlutterVulkanQueueHandle;
/// Alias for VkImage.
typedef uint64_t FlutterVulkanImageHandle;

/// Alias for VkDeviceMemory.
typedef uint64_t FlutterVulkanDeviceMemoryHandle;

typedef struct {
/// The size of this struct. Must be sizeof(FlutterVulkanImage).
size_t struct_size;
Expand Down Expand Up @@ -952,6 +955,36 @@ typedef bool (*FlutterVulkanPresentCallback)(
void* /* user data */,
const FlutterVulkanImage* /* image */);

typedef struct {
/// Handle to the VkImage that is owned by the embedder. The engine will
/// bind this image for writing the frame.
FlutterVulkanImageHandle image;
/// The VkDeviceMemory that backs the iamge.
FlutterVulkanDeviceMemoryHandle image_memory;
/// The VkFormat of the image (for example: VK_FORMAT_R8G8B8A8_UNORM).
uint32_t format;
/// User data to be returned on the invocation of the destruction callback.
void* user_data;
/// Callback invoked (on an engine managed thread) that asks the embedder to
/// collect the texture.
VoidCallback destruction_callback;
/// Optional parameters for texture height/width, default is 0, non-zero means
/// the texture has the specified width/height.
/// Width of the texture.
size_t width;
/// Height of the texture.
size_t height;
} FlutterVulkanTexture;

/// Callback to provide an external texture for a given texture_id.
/// See: external_texture_frame_callback.
typedef bool (*FlutterVulkanTextureFrameCallback)(
void* /* user data */,
int64_t /* texture identifier */,
size_t /* width */,
size_t /* height */,
FlutterVulkanTexture* /* texture out */);

typedef struct {
/// The size of this struct. Must be sizeof(FlutterVulkanRendererConfig).
size_t struct_size;
Expand Down Expand Up @@ -1015,7 +1048,11 @@ typedef struct {
/// without any additional synchronization.
/// Not used if a FlutterCompositor is supplied in FlutterProjectArgs.
FlutterVulkanPresentCallback present_image_callback;

/// When the embedder specifies that a texture has a frame available, the
/// engine will call this method (on an internal engine managed thread) so
/// that external texture details can be supplied to the engine for subsequent
/// composition.
FlutterVulkanTextureFrameCallback external_texture_frame_callback;
} FlutterVulkanRendererConfig;

typedef struct {
Expand Down
8 changes: 7 additions & 1 deletion flutter/shell/platform/tizen/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,13 @@ template("embedder") {
target_name == "flutter_tizen_tv_experimental" ||
target_name == "flutter_tizen_common_experimental") {
defines += [ "FLUTTER_TIZEN_EXPERIMENTAL" ]
sources += [ "tizen_renderer_vulkan.cc" ]
sources += [
"external_texture_pixel_vulkan.cc",
"external_texture_surface_vulkan.cc",
"external_texture_surface_vulkan_buffer.cc",
"external_texture_surface_vulkan_buffer_dma.cc",
"tizen_renderer_vulkan.cc",
]
deps += [ "//flutter/third_party/volk" ]
}

Expand Down
47 changes: 31 additions & 16 deletions flutter/shell/platform/tizen/external_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,51 @@

namespace flutter {

static std::atomic<int64_t> next_texture_id = {1};

class ExternalTexture {
public:
ExternalTexture() : texture_id_(next_texture_id++) {}

virtual ~ExternalTexture() = default;

// Returns the unique id for the ExternalTextureGL instance.
int64_t TextureId() { return texture_id_; }

protected:
const int64_t texture_id_ = 0;
};

enum class ExternalTextureExtensionType { kNone, kNativeSurface, kDmaBuffer };

struct ExternalTextureGLState {
uint32_t gl_texture;
ExternalTextureExtensionType gl_extension;
};

static std::atomic<int64_t> next_texture_id = {1};

class ExternalTexture {
class ExternalGLTexture : public ExternalTexture {
public:
ExternalTexture(ExternalTextureExtensionType gl_extension =
ExternalTextureExtensionType::kNone)
: state_(std::make_unique<ExternalTextureGLState>()),
texture_id_(next_texture_id++) {
ExternalGLTexture(ExternalTextureExtensionType gl_extension =
ExternalTextureExtensionType::kNone)
: ExternalTexture(), state_(std::make_unique<ExternalTextureGLState>()) {
state_->gl_extension = gl_extension;
}

virtual ~ExternalTexture() = default;

// Returns the unique id for the ExternalTextureGL instance.
int64_t TextureId() { return texture_id_; }

virtual bool PopulateTexture(size_t width,
size_t height,
FlutterOpenGLTexture* opengl_texture) = 0;
virtual bool PopulateGLTexture(size_t width,
size_t height,
FlutterOpenGLTexture* opengl_texture) = 0;

protected:
std::unique_ptr<ExternalTextureGLState> state_;
const int64_t texture_id_ = 0;
};

class ExternalVulkanTexture : public ExternalTexture {
public:
ExternalVulkanTexture() : ExternalTexture() {}

virtual bool PopulateVulkanTexture(size_t width,
size_t height,
FlutterVulkanTexture* vulkan_texture) = 0;
};

} // namespace flutter
Expand Down
4 changes: 2 additions & 2 deletions flutter/shell/platform/tizen/external_texture_pixel_egl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace flutter {

bool ExternalTexturePixelEGL::PopulateTexture(
bool ExternalTexturePixelEGL::PopulateGLTexture(
size_t width,
size_t height,
FlutterOpenGLTexture* opengl_texture) {
Expand All @@ -33,7 +33,7 @@ bool ExternalTexturePixelEGL::PopulateTexture(
ExternalTexturePixelEGL::ExternalTexturePixelEGL(
FlutterDesktopPixelBufferTextureCallback texture_callback,
void* user_data)
: ExternalTexture(),
: ExternalGLTexture(),
texture_callback_(texture_callback),
user_data_(user_data) {}

Expand Down
8 changes: 4 additions & 4 deletions flutter/shell/platform/tizen/external_texture_pixel_egl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

namespace flutter {

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

~ExternalTexturePixelEGL() = default;

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace flutter {

bool ExternalTexturePixelEGLImpeller::PopulateTexture(
bool ExternalTexturePixelEGLImpeller::PopulateGLTexture(
size_t width,
size_t height,
FlutterOpenGLTexture* opengl_texture) {
Expand Down Expand Up @@ -43,7 +43,7 @@ bool ExternalTexturePixelEGLImpeller::PopulateTexture(
ExternalTexturePixelEGLImpeller::ExternalTexturePixelEGLImpeller(
FlutterDesktopPixelBufferTextureCallback texture_callback,
void* user_data)
: ExternalTexture(),
: ExternalGLTexture(),
texture_callback_(texture_callback),
user_data_(user_data) {}

Expand Down
8 changes: 4 additions & 4 deletions flutter/shell/platform/tizen/external_texture_pixel_egl_impeller.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

namespace flutter {

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

~ExternalTexturePixelEGLImpeller() = default;

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

private:
FlutterDesktopPixelBufferTextureCallback texture_callback_ = nullptr;
Expand Down
Loading