This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Add windows plugin texture support #19405
Merged
fluttergithubbot
merged 18 commits into
flutter:master
from
jnschulze:feature/windows-textures
Jan 19, 2021
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0c365e9
Add windows plugin texture support
jnschulze f07da6f
[windows] Rename Texture to PixelBufferTexture and make it a variant
jnschulze a44de99
Embedder API: Add PostPlatformThreadTask method
jnschulze 92279aa
Windows textures: Allow calling MarkTextureFrameAvailable from arbitr…
jnschulze 0c1c2f1
Windows textures: Do review-related cleanup
jnschulze f3d0dc4
Windows textures: Remove message when copying a pixel buffer fails as…
jnschulze b94d4f4
Embedder API: Add missing FlutterEnginePostPlatformThreadTask declara…
jnschulze 018e479
Embedder API: Move PostPlatformThreadTask to end of proc table
jnschulze d9e7d5e
Windows textures: Make PixelBufferTexture's copy cb return type const
jnschulze 6a8a20e
Windows: Extend TaskRunner to allow direct posting
jnschulze 256db6a
Windows textures: Use TaskRunner::PostTask
jnschulze fa22152
Revert "Embedder API: Add PostPlatformThreadTask method"
jnschulze cfe1b34
Windows textures: Make texture registration/unregistration thread safe
jnschulze 1d8057d
Windows textures: Improve comments in terms of thread safety
jnschulze c69c927
Windows task runner: PostTask: Remove unused target_time parameter
jnschulze 8e2a2bc
Windows textures: minimize lock scope
jnschulze 3e9977e
Windows textures: Clean up comments
jnschulze f4d3608
Merge branch 'master' into feature/windows-textures
jnschulze 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
75 changes: 75 additions & 0 deletions
75
shell/platform/common/cpp/client_wrapper/include/flutter/texture_registrar.h
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,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 { | ||
jnschulze marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 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
40 changes: 40 additions & 0 deletions
40
shell/platform/common/cpp/client_wrapper/texture_registrar_impl.h
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,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; | ||
jnschulze marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // |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.
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.