forked from flutter/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.
Add windows plugin texture support (flutter#19405)
- Loading branch information
Showing
31 changed files
with
1,138 additions
and
21 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
75 changes: 75 additions & 0 deletions
75
shell/platform/common/cpp/client_wrapper/include/flutter/texture_registrar.h
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,75 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef FLUTTER_SHELL_PLATFORM_COMMON_CPP_CLIENT_WRAPPER_INCLUDE_FLUTTER_TEXTURE_REGISTRAR_H_ | ||
#define FLUTTER_SHELL_PLATFORM_COMMON_CPP_CLIENT_WRAPPER_INCLUDE_FLUTTER_TEXTURE_REGISTRAR_H_ | ||
|
||
#include <flutter_texture_registrar.h> | ||
|
||
#include <cstdint> | ||
#include <functional> | ||
#include <memory> | ||
#include <variant> | ||
|
||
namespace flutter { | ||
|
||
// A pixel buffer texture. | ||
class PixelBufferTexture { | ||
public: | ||
// A callback used for retrieving pixel buffers. | ||
typedef std::function<const FlutterDesktopPixelBuffer*(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. | ||
PixelBufferTexture(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 FlutterDesktopPixelBuffer* CopyPixelBuffer(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; | ||
|
||
// An object keeping track of external textures. | ||
// | ||
// Thread safety: | ||
// It's safe to call the member methods from any thread. | ||
class TextureRegistrar { | ||
public: | ||
virtual ~TextureRegistrar() = default; | ||
|
||
// Registers a |texture| object and returns the ID for that texture. | ||
virtual int64_t RegisterTexture(TextureVariant* texture) = 0; | ||
|
||
// Notifies the flutter engine that the texture object corresponding | ||
// to |texure_id| needs to render a new frame. | ||
// | ||
// For PixelBufferTextures, this will effectively make the engine invoke | ||
// the callback that was provided upon creating the texture. | ||
virtual bool MarkTextureFrameAvailable(int64_t texture_id) = 0; | ||
|
||
// Unregisters an existing Texture object. | ||
// Textures must not be unregistered while they're in use. | ||
virtual bool UnregisterTexture(int64_t texture_id) = 0; | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
#endif // FLUTTER_SHELL_PLATFORM_COMMON_CPP_CLIENT_WRAPPER_INCLUDE_FLUTTER_TEXTURE_REGISTRAR_H_ |
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
40 changes: 40 additions & 0 deletions
40
shell/platform/common/cpp/client_wrapper/texture_registrar_impl.h
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,40 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef FLUTTER_SHELL_PLATFORM_COMMON_CPP_CLIENT_WRAPPER_TEXTURE_REGISTRAR_IMPL_H_ | ||
#define FLUTTER_SHELL_PLATFORM_COMMON_CPP_CLIENT_WRAPPER_TEXTURE_REGISTRAR_IMPL_H_ | ||
|
||
#include "include/flutter/texture_registrar.h" | ||
|
||
namespace flutter { | ||
|
||
// Wrapper around a FlutterDesktopTextureRegistrarRef that implements the | ||
// TextureRegistrar API. | ||
class TextureRegistrarImpl : public TextureRegistrar { | ||
public: | ||
explicit TextureRegistrarImpl( | ||
FlutterDesktopTextureRegistrarRef texture_registrar_ref); | ||
virtual ~TextureRegistrarImpl(); | ||
|
||
// Prevent copying. | ||
TextureRegistrarImpl(TextureRegistrarImpl const&) = delete; | ||
TextureRegistrarImpl& operator=(TextureRegistrarImpl const&) = delete; | ||
|
||
// |flutter::TextureRegistrar| | ||
int64_t RegisterTexture(TextureVariant* texture) override; | ||
|
||
// |flutter::TextureRegistrar| | ||
bool MarkTextureFrameAvailable(int64_t texture_id) override; | ||
|
||
// |flutter::TextureRegistrar| | ||
bool UnregisterTexture(int64_t texture_id) override; | ||
|
||
private: | ||
// Handle for interacting with the C API. | ||
FlutterDesktopTextureRegistrarRef texture_registrar_ref_; | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
#endif // FLUTTER_SHELL_PLATFORM_COMMON_CPP_CLIENT_WRAPPER_TEXTURE_REGISTRAR_IMPL_H_ |
Oops, something went wrong.