Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
500e60c
Define structs, class
yaakovschectman Feb 8, 2024
8dd4543
Define PV type registration runner API function
yaakovschectman Feb 8, 2024
ae0d049
Bare minimum PlatformViewHandler
yaakovschectman Feb 8, 2024
5f14af0
Compositor owns platform view manager
yaakovschectman Feb 8, 2024
200f13a
Set up for mocking
yaakovschectman Feb 8, 2024
ed90810
Add unit test
yaakovschectman Feb 13, 2024
5d410ff
Formatting
yaakovschectman Feb 13, 2024
484c8c1
License fix, await future
yaakovschectman Feb 13, 2024
b8fadd7
PR Feedback
yaakovschectman Feb 13, 2024
1d203f4
_internal header file
yaakovschectman Feb 14, 2024
b9acc1a
Wait to add manager to compositors
yaakovschectman Feb 14, 2024
35eb688
Rename fixture function
yaakovschectman Feb 14, 2024
659ebd6
Reorder parameters
yaakovschectman Feb 14, 2024
db2851b
Use constants
yaakovschectman Feb 14, 2024
db48ddd
Reorder params in test
yaakovschectman Feb 14, 2024
f87ed96
Format
yaakovschectman Feb 14, 2024
42f976e
License
yaakovschectman Feb 14, 2024
284b309
Break up PlatformViewManager
yaakovschectman Feb 16, 2024
e000930
PR Feedback
yaakovschectman Feb 16, 2024
676868f
Formatting
yaakovschectman Feb 16, 2024
6e6ef7e
PR Feedback
yaakovschectman Feb 16, 2024
22a9e46
Update shell/platform/windows/flutter_windows_engine_unittests.cc
yaakovschectman Feb 21, 2024
95a8498
Update shell/platform/windows/platform_view_manager.h
yaakovschectman Feb 21, 2024
1fa97f3
Update shell/platform/windows/public/flutter_windows.h
yaakovschectman Feb 21, 2024
5453b29
Update shell/platform/windows/flutter_windows_engine_unittests.cc
yaakovschectman Feb 21, 2024
dfa6b73
PR Feedback
yaakovschectman Feb 21, 2024
cde468e
Merge branch 'main' into win_pv_i
yaakovschectman Feb 21, 2024
585ca11
Include internal header
yaakovschectman Feb 22, 2024
54d91a3
Merge branch 'main' into win_pv_i
yaakovschectman Feb 22, 2024
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
Prev Previous commit
Next Next commit
Bare minimum PlatformViewHandler
  • Loading branch information
yaakovschectman committed Feb 8, 2024
commit ae0d0492664da3026e74a853f3087bf5420a2c5a
24 changes: 24 additions & 0 deletions shell/platform/windows/platform_view_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@

#include "flutter/shell/platform/windows/platform_view_manager.h"

#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_method_codec.h"

namespace flutter {

namespace {
constexpr char kChannelName[] = "";
}

PlatformViewManager::PlatformViewManager(TaskRunner* task_runner, BinaryMessenger* binary_messenger) : task_runner_(task_runner), channel_(std::make_unique<MethodChannel<EncodableValue>>(binary_messenger, kChannelName, &StandardMethodCodec::GetInstance())) {
channel_->SetMethodCallHandler([](const MethodCall<EncodableValue>& call, std::unique_ptr<MethodResult<EncodableValue>> result){
result->Success();
});
}

void PlatformViewManager::QueuePlatformViewCreation(std::string_view type_name, int64_t id) {}

void PlatformViewManager::InstantiatePlatformView(int64_t id) {}

void PlatformViewManager::RegisterPlatformViewType(std::string_view type_name, const FlutterPlatformViewTypeEntry& type) {}

void PlatformViewManager::FocusPlatformView(int64_t id, FocusChangeDirection direction, bool focus) {}

std::optional<HWND> PlatformViewManager::GetNativeHandleForId(int64_t id) const {
return std::nullopt;
}

} // namespace flutter
23 changes: 22 additions & 1 deletion shell/platform/windows/platform_view_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,46 @@
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_PLATFORM_VIEW_MANAGER_H_
#define FLUTTER_SHELL_PLATFORM_WINDOWS_PLATFORM_VIEW_MANAGER_H_

#include <functional>
#include <map>
#include <memory>
#include <optional>

#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h"
#include "flutter/shell/platform/windows/public/flutter_windows.h"
#include "flutter/shell/platform/windows/task_runner.h"

namespace flutter {

enum class FocusChangeDirection {
kProgrammatic,
kForward,
kBackward
};

class PlatformViewManager {
public:
PlatformViewManager(TaskRunner* task_runner, BinaryMessenger* binary_messenger);

void QueuePlatformViewCreation(std::string_view type_name, int64_t id);

void InstantiatePlatformView(int64_t id);

void RegisterPlatformViewType(std::string_view type_name, const FlutterPlatformViewTypeEntry& type);

void FocusPlatformView(int64_t id, FocusChangeDirection direction, bool focus);

std::optional<HWND> GetNativeHandleForId(int64_t id) const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we gaining by using a std::optional here over just returning nullptr, since HWND is already a pointer type? In both cases, the caller is left with:

auto platform_view = GetNativeHandleForId(pvid);
if (platform_view) {
  ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an indicator that this may return null when the id is bad. We can return just HWND and state this in a comment instead.

private:
std::unique_ptr<MethodChannel<EncodableValue>> channel_;

std::map<std::string, FlutterPlatformViewTypeEntry> platform_view_types_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below, unless ordering is required, prefer std::unordered_map. I realise we're pretty inconsistent in existing code about this.


std::map<int64_t, HWND> platform_views_;

std::map<int64_t, FlutterPlatformViewCreationParameters> pending_platform_views_;
std::map<int64_t, std::function<HWND()>> pending_platform_views_;

TaskRunner* task_runner_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment on ownership.

};

} // namespace flutter
Expand Down
1 change: 1 addition & 0 deletions shell/platform/windows/public/flutter_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ typedef struct {
typedef HWND (*FlutterPlatformViewFactory)(const FlutterPlatformViewCreationParameters*);

typedef struct {
size_t cb_size;
FlutterPlatformViewFactory factory;
void* user_data;
} FlutterPlatformViewTypeEntry;
Expand Down