react-native-windows 0.74.0 → 0.74.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/Components/Touchable/TouchableBounce.js +1 -0
- package/Libraries/Components/Touchable/TouchableOpacity.js +1 -0
- package/Libraries/Components/Touchable/TouchableOpacity.windows.js +1 -0
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/Microsoft.ReactNative/CompositionRootView.idl +4 -2
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +6 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +188 -141
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.cpp +41 -34
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.h +5 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView_emptyimpl.cpp +7 -0
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +26 -13
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +3 -2
- package/Microsoft.ReactNative/Fabric/Composition/ImageResponseImage.h +17 -0
- package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +28 -10
- package/Microsoft.ReactNative/Fabric/Composition/Theme.h +4 -3
- package/Microsoft.ReactNative/Fabric/Composition/Theme_emptyimpl.cpp +2 -6
- package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.cpp +82 -0
- package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.h +39 -0
- package/Microsoft.ReactNative/Fabric/Composition/UriImageManager_emptyimpl.cpp +16 -0
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +3 -0
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +2 -0
- package/Microsoft.ReactNative/Fabric/ImageManager.cpp +3 -2
- package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +102 -35
- package/Microsoft.ReactNative/Fabric/WindowsImageManager.h +6 -1
- package/Microsoft.ReactNative/Theme.idl +1 -2
- package/Microsoft.ReactNative/UriImageManager.idl +85 -0
- package/Microsoft.ReactNative.Cxx/AutoDraw.h +1 -0
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/Shared/Shared.vcxitems +11 -0
- package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +33 -21
- package/codegen/rnwcoreJSI-generated.cpp +18 -6
- package/codegen/rnwcoreJSI.h +27 -9
- package/package.json +14 -14
- package/src/private/featureflags/NativeReactNativeFeatureFlags.js +4 -2
- package/src/private/featureflags/ReactNativeFeatureFlags.js +16 -6
|
@@ -131,6 +131,13 @@ CompositionRootView::CompositionRootView(const winrt::Microsoft::UI::Composition
|
|
|
131
131
|
: m_compositor(compositor) {}
|
|
132
132
|
#endif
|
|
133
133
|
|
|
134
|
+
CompositionRootView::~CompositionRootView() noexcept {
|
|
135
|
+
if (m_uiDispatcher) {
|
|
136
|
+
assert(m_uiDispatcher.HasThreadAccess());
|
|
137
|
+
UninitRootView();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
134
141
|
ReactNative::IReactViewHost CompositionRootView::ReactViewHost() noexcept {
|
|
135
142
|
return m_reactViewHost;
|
|
136
143
|
}
|
|
@@ -240,29 +247,32 @@ void CompositionRootView::ScaleFactor(float value) noexcept {
|
|
|
240
247
|
}
|
|
241
248
|
}
|
|
242
249
|
|
|
250
|
+
winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader CompositionRootView::Resources() noexcept {
|
|
251
|
+
return m_resources;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
void CompositionRootView::Resources(
|
|
255
|
+
const winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader &resources) noexcept {
|
|
256
|
+
m_resources = resources;
|
|
257
|
+
|
|
258
|
+
if (m_context && m_theme) {
|
|
259
|
+
Theme(winrt::make<winrt::Microsoft::ReactNative::Composition::implementation::Theme>(m_context, m_resources));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
243
263
|
winrt::Microsoft::ReactNative::Composition::Theme CompositionRootView::Theme() noexcept {
|
|
244
264
|
if (!m_theme) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
IInspectable const & /*sender*/,
|
|
252
|
-
winrt::Microsoft::ReactNative::ReactNotificationArgs<void> const & /*args*/) {
|
|
253
|
-
auto pThis = wkThis.get();
|
|
254
|
-
pThis->Theme(winrt::Microsoft::ReactNative::Composition::Theme::GetDefaultTheme(pThis->m_context.Handle()));
|
|
255
|
-
});
|
|
265
|
+
assert(m_context);
|
|
266
|
+
if (m_resources) {
|
|
267
|
+
Theme(winrt::make<winrt::Microsoft::ReactNative::Composition::implementation::Theme>(m_context, m_resources));
|
|
268
|
+
} else {
|
|
269
|
+
Theme(winrt::Microsoft::ReactNative::Composition::Theme::GetDefaultTheme(m_context.Handle()));
|
|
270
|
+
}
|
|
256
271
|
}
|
|
257
272
|
return m_theme;
|
|
258
273
|
}
|
|
259
274
|
|
|
260
275
|
void CompositionRootView::Theme(const winrt::Microsoft::ReactNative::Composition::Theme &value) noexcept {
|
|
261
|
-
if (m_themeChangedSubscription) {
|
|
262
|
-
m_themeChangedSubscription.Unsubscribe();
|
|
263
|
-
m_themeChangedSubscription = nullptr;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
276
|
if (value == m_theme)
|
|
267
277
|
return;
|
|
268
278
|
|
|
@@ -270,20 +280,22 @@ void CompositionRootView::Theme(const winrt::Microsoft::ReactNative::Composition
|
|
|
270
280
|
|
|
271
281
|
m_themeChangedRevoker = m_theme.ThemeChanged(
|
|
272
282
|
winrt::auto_revoke,
|
|
273
|
-
[
|
|
283
|
+
[wkThis = get_weak()](
|
|
274
284
|
const winrt::Windows::Foundation::IInspectable & /*sender*/,
|
|
275
285
|
const winrt::Windows::Foundation::IInspectable & /*args*/) {
|
|
276
|
-
if (auto
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
winrt::
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
286
|
+
if (auto strongThis = wkThis.get()) {
|
|
287
|
+
if (auto rootView = strongThis->GetComponentView()) {
|
|
288
|
+
Mso::Functor<bool(const winrt::Microsoft::ReactNative::ComponentView &)> fn =
|
|
289
|
+
[](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
|
|
290
|
+
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(view)->onThemeChanged();
|
|
291
|
+
return false;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
winrt::Microsoft::ReactNative::ComponentView view{nullptr};
|
|
295
|
+
winrt::check_hresult(rootView->QueryInterface(
|
|
296
|
+
winrt::guid_of<winrt::Microsoft::ReactNative::ComponentView>(), winrt::put_abi(view)));
|
|
297
|
+
walkTree(view, true, fn);
|
|
298
|
+
}
|
|
287
299
|
}
|
|
288
300
|
});
|
|
289
301
|
|
|
@@ -382,13 +394,8 @@ void CompositionRootView::InitRootView(
|
|
|
382
394
|
}
|
|
383
395
|
|
|
384
396
|
m_context = winrt::Microsoft::ReactNative::ReactContext(std::move(context));
|
|
385
|
-
|
|
386
|
-
winrt::Microsoft::ReactNative::CompositionRootView compositionRootView;
|
|
387
|
-
get_strong().as(compositionRootView);
|
|
388
|
-
|
|
389
397
|
m_reactViewOptions = std::move(viewOptions);
|
|
390
|
-
m_CompositionEventHandler =
|
|
391
|
-
std::make_shared<::Microsoft::ReactNative::CompositionEventHandler>(m_context, compositionRootView);
|
|
398
|
+
m_CompositionEventHandler = std::make_shared<::Microsoft::ReactNative::CompositionEventHandler>(m_context, *this);
|
|
392
399
|
|
|
393
400
|
UpdateRootViewInternal();
|
|
394
401
|
|
|
@@ -45,6 +45,7 @@ struct CompositionRootView
|
|
|
45
45
|
: CompositionRootViewT<CompositionRootView, Composition::Experimental::IInternalCompositionRootView>,
|
|
46
46
|
::Microsoft::ReactNative::ICompositionRootView {
|
|
47
47
|
CompositionRootView() noexcept;
|
|
48
|
+
~CompositionRootView() noexcept;
|
|
48
49
|
|
|
49
50
|
#ifdef USE_WINUI3
|
|
50
51
|
CompositionRootView(const winrt::Microsoft::UI::Composition::Compositor &compositor) noexcept;
|
|
@@ -73,6 +74,9 @@ struct CompositionRootView
|
|
|
73
74
|
void RemoveRenderedVisual(const winrt::Microsoft::ReactNative::Composition::Experimental::IVisual &visual) noexcept;
|
|
74
75
|
bool TrySetFocus() noexcept;
|
|
75
76
|
|
|
77
|
+
winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader Resources() noexcept;
|
|
78
|
+
void Resources(const winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader &resources) noexcept;
|
|
79
|
+
|
|
76
80
|
winrt::Microsoft::ReactNative::Composition::Theme Theme() noexcept;
|
|
77
81
|
void Theme(const winrt::Microsoft::ReactNative::Composition::Theme &value) noexcept;
|
|
78
82
|
|
|
@@ -134,8 +138,8 @@ struct CompositionRootView
|
|
|
134
138
|
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual m_rootVisual{nullptr};
|
|
135
139
|
winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_loadingVisual{nullptr};
|
|
136
140
|
winrt::Microsoft::ReactNative::Composition::Experimental::IActivityVisual m_loadingActivityVisual{nullptr};
|
|
141
|
+
winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader m_resources{nullptr};
|
|
137
142
|
winrt::Microsoft::ReactNative::Composition::Theme m_theme{nullptr};
|
|
138
|
-
winrt::Microsoft::ReactNative::ReactNotificationSubscription m_themeChangedSubscription{nullptr};
|
|
139
143
|
winrt::Microsoft::ReactNative::Composition::Theme::ThemeChanged_revoker m_themeChangedRevoker;
|
|
140
144
|
|
|
141
145
|
void UpdateRootViewInternal() noexcept;
|
|
@@ -28,6 +28,7 @@ struct CompositionReactViewInstance
|
|
|
28
28
|
//===========================================================================
|
|
29
29
|
|
|
30
30
|
CompositionRootView::CompositionRootView() noexcept {}
|
|
31
|
+
CompositionRootView::~CompositionRootView() noexcept {}
|
|
31
32
|
|
|
32
33
|
CompositionRootView::CompositionRootView(const winrt::Microsoft::UI::Composition::Compositor &compositor) noexcept {}
|
|
33
34
|
|
|
@@ -69,6 +70,12 @@ winrt::Microsoft::ReactNative::Composition::Theme CompositionRootView::Theme() n
|
|
|
69
70
|
}
|
|
70
71
|
void CompositionRootView::Theme(const winrt::Microsoft::ReactNative::Composition::Theme &) noexcept {}
|
|
71
72
|
|
|
73
|
+
winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader CompositionRootView::Resources() noexcept {
|
|
74
|
+
return nullptr;
|
|
75
|
+
}
|
|
76
|
+
void CompositionRootView::Resources(
|
|
77
|
+
const winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader &) noexcept {}
|
|
78
|
+
|
|
72
79
|
winrt::IInspectable CompositionRootView::GetUiaProvider() noexcept {
|
|
73
80
|
return nullptr;
|
|
74
81
|
}
|
|
@@ -39,9 +39,9 @@ void ImageComponentView::WindowsImageResponseObserver::didReceiveProgress(float
|
|
|
39
39
|
|
|
40
40
|
void ImageComponentView::WindowsImageResponseObserver::didReceiveImage(
|
|
41
41
|
facebook::react::ImageResponse const &imageResponse) const {
|
|
42
|
-
auto
|
|
42
|
+
auto imageResponseImage = std::static_pointer_cast<ImageResponseImage>(imageResponse.getImage());
|
|
43
43
|
m_image->m_reactContext.UIDispatcher().Post(
|
|
44
|
-
[
|
|
44
|
+
[imageResponseImage, image = m_image]() { image->didReceiveImage(imageResponseImage); });
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
void ImageComponentView::WindowsImageResponseObserver::didReceiveFailure() const {
|
|
@@ -83,7 +83,7 @@ void ImageComponentView::ImageLoadStart() noexcept {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
void ImageComponentView::didReceiveImage(const
|
|
86
|
+
void ImageComponentView::didReceiveImage(const std::shared_ptr<ImageResponseImage> &imageResponseImage) noexcept {
|
|
87
87
|
// TODO check for recycled?
|
|
88
88
|
|
|
89
89
|
auto imageEventEmitter = std::static_pointer_cast<facebook::react::ImageEventEmitter const>(m_eventEmitter);
|
|
@@ -99,7 +99,7 @@ void ImageComponentView::didReceiveImage(const winrt::com_ptr<IWICBitmap> &wicbm
|
|
|
99
99
|
assert(uiDispatcher.HasThreadAccess());
|
|
100
100
|
#endif
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
m_imageResponseImage = imageResponseImage;
|
|
103
103
|
ensureDrawingSurface();
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -198,7 +198,8 @@ void ImageComponentView::updateLayoutMetrics(
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
void ImageComponentView::OnRenderingDeviceLost() noexcept {
|
|
201
|
-
|
|
201
|
+
m_drawingSurface = nullptr;
|
|
202
|
+
ensureDrawingSurface();
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
bool ImageComponentView::themeEffectsImage() const noexcept {
|
|
@@ -207,7 +208,8 @@ bool ImageComponentView::themeEffectsImage() const noexcept {
|
|
|
207
208
|
|
|
208
209
|
void ImageComponentView::onThemeChanged() noexcept {
|
|
209
210
|
if (themeEffectsImage()) {
|
|
210
|
-
|
|
211
|
+
m_drawingSurface = nullptr;
|
|
212
|
+
ensureDrawingSurface();
|
|
211
213
|
}
|
|
212
214
|
Super::onThemeChanged();
|
|
213
215
|
}
|
|
@@ -215,10 +217,17 @@ void ImageComponentView::onThemeChanged() noexcept {
|
|
|
215
217
|
void ImageComponentView::ensureDrawingSurface() noexcept {
|
|
216
218
|
assert(m_reactContext.UIDispatcher().HasThreadAccess());
|
|
217
219
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
+
if (!m_imageResponseImage) {
|
|
221
|
+
m_visual.Brush(nullptr);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
UINT width = 0, height = 0;
|
|
226
|
+
if (m_imageResponseImage->m_wicbmp) {
|
|
227
|
+
winrt::check_hresult(m_imageResponseImage->m_wicbmp->GetSize(&width, &height));
|
|
228
|
+
}
|
|
220
229
|
|
|
221
|
-
if (!m_drawingSurface && m_wicbmp) {
|
|
230
|
+
if (!m_drawingSurface && m_imageResponseImage->m_wicbmp) {
|
|
222
231
|
winrt::Windows::Foundation::Size drawingSurfaceSize{static_cast<float>(width), static_cast<float>(height)};
|
|
223
232
|
|
|
224
233
|
const auto imageProps = std::static_pointer_cast<const facebook::react::ImageProps>(m_props);
|
|
@@ -273,6 +282,8 @@ void ImageComponentView::ensureDrawingSurface() noexcept {
|
|
|
273
282
|
}
|
|
274
283
|
|
|
275
284
|
m_visual.Brush(m_drawingSurface);
|
|
285
|
+
} else if (m_imageResponseImage->m_brushFactory) {
|
|
286
|
+
m_visual.Brush(m_imageResponseImage->m_brushFactory(m_reactContext.Handle(), m_compContext));
|
|
276
287
|
}
|
|
277
288
|
}
|
|
278
289
|
|
|
@@ -286,7 +297,7 @@ void ImageComponentView::DrawImage() noexcept {
|
|
|
286
297
|
return;
|
|
287
298
|
}
|
|
288
299
|
|
|
289
|
-
if (!m_wicbmp) {
|
|
300
|
+
if (!m_imageResponseImage->m_wicbmp) {
|
|
290
301
|
return;
|
|
291
302
|
}
|
|
292
303
|
|
|
@@ -295,7 +306,8 @@ void ImageComponentView::DrawImage() noexcept {
|
|
|
295
306
|
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(m_drawingSurface, 1.0f, &offset);
|
|
296
307
|
if (auto d2dDeviceContext = autoDraw.GetRenderTarget()) {
|
|
297
308
|
winrt::com_ptr<ID2D1Bitmap1> bitmap;
|
|
298
|
-
winrt::check_hresult(
|
|
309
|
+
winrt::check_hresult(
|
|
310
|
+
d2dDeviceContext->CreateBitmapFromWicBitmap(m_imageResponseImage->m_wicbmp.get(), nullptr, bitmap.put()));
|
|
299
311
|
|
|
300
312
|
d2dDeviceContext->Clear(D2D1::ColorF(D2D1::ColorF::Black, 0.0f));
|
|
301
313
|
if (m_props->backgroundColor) {
|
|
@@ -311,7 +323,8 @@ void ImageComponentView::DrawImage() noexcept {
|
|
|
311
323
|
if (useEffects) {
|
|
312
324
|
winrt::com_ptr<ID2D1Effect> bitmapEffects;
|
|
313
325
|
winrt::check_hresult(d2dDeviceContext->CreateEffect(CLSID_D2D1BitmapSource, bitmapEffects.put()));
|
|
314
|
-
winrt::check_hresult(
|
|
326
|
+
winrt::check_hresult(
|
|
327
|
+
bitmapEffects->SetValue(D2D1_BITMAPSOURCE_PROP_WIC_BITMAP_SOURCE, m_imageResponseImage->m_wicbmp.get()));
|
|
315
328
|
|
|
316
329
|
if (imageProps->blurRadius > 0) {
|
|
317
330
|
winrt::com_ptr<ID2D1Effect> gaussianBlurEffect;
|
|
@@ -360,7 +373,7 @@ void ImageComponentView::DrawImage() noexcept {
|
|
|
360
373
|
}
|
|
361
374
|
} else {
|
|
362
375
|
UINT width, height;
|
|
363
|
-
winrt::check_hresult(m_wicbmp->GetSize(&width, &height));
|
|
376
|
+
winrt::check_hresult(m_imageResponseImage->m_wicbmp->GetSize(&width, &height));
|
|
364
377
|
|
|
365
378
|
D2D1_RECT_F rect = D2D1::RectF(
|
|
366
379
|
static_cast<float>(offset.x),
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
#include <winrt/Windows.UI.Composition.h>
|
|
15
15
|
#include "CompositionHelpers.h"
|
|
16
16
|
#include "CompositionViewComponentView.h"
|
|
17
|
+
#include "ImageResponseImage.h"
|
|
17
18
|
|
|
18
19
|
#pragma warning(push)
|
|
19
20
|
#pragma warning(disable : 4244 4305)
|
|
@@ -83,7 +84,7 @@ struct ImageComponentView : ImageComponentViewT<ImageComponentView, ComponentVie
|
|
|
83
84
|
|
|
84
85
|
void ImageLoadStart() noexcept;
|
|
85
86
|
void ImageLoaded() noexcept;
|
|
86
|
-
void didReceiveImage(const
|
|
87
|
+
void didReceiveImage(const std::shared_ptr<ImageResponseImage> &wicbmp) noexcept;
|
|
87
88
|
void didReceiveFailureFromObserver() noexcept;
|
|
88
89
|
void setStateAndResubscribeImageResponseObserver(
|
|
89
90
|
facebook::react::ImageShadowNode::ConcreteState::Shared const &state) noexcept;
|
|
@@ -93,7 +94,7 @@ struct ImageComponentView : ImageComponentViewT<ImageComponentView, ComponentVie
|
|
|
93
94
|
|
|
94
95
|
winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_visual{nullptr};
|
|
95
96
|
winrt::Microsoft::ReactNative::Composition::Experimental::IDrawingSurfaceBrush m_drawingSurface;
|
|
96
|
-
|
|
97
|
+
std::shared_ptr<ImageResponseImage> m_imageResponseImage;
|
|
97
98
|
std::shared_ptr<WindowsImageResponseObserver> m_imageResponseObserver;
|
|
98
99
|
facebook::react::ImageShadowNode::ConcreteState::Shared m_state;
|
|
99
100
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <wincodec.h>
|
|
8
|
+
#include <winrt/Microsoft.ReactNative.Composition.Experimental.h>
|
|
9
|
+
|
|
10
|
+
namespace winrt::Microsoft::ReactNative::Composition::implementation {
|
|
11
|
+
|
|
12
|
+
struct ImageResponseImage {
|
|
13
|
+
winrt::com_ptr<IWICBitmap> m_wicbmp;
|
|
14
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::UriBrushFactory m_brushFactory{nullptr};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|
|
@@ -526,6 +526,15 @@ static const winrt::Microsoft::ReactNative::ReactPropertyId<winrt::Microsoft::Re
|
|
|
526
526
|
return prop;
|
|
527
527
|
}
|
|
528
528
|
|
|
529
|
+
static const winrt::Microsoft::ReactNative::ReactPropertyId<
|
|
530
|
+
winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader>
|
|
531
|
+
&ThemeResourcesPropertyId() noexcept {
|
|
532
|
+
static const winrt::Microsoft::ReactNative::ReactPropertyId<
|
|
533
|
+
winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader>
|
|
534
|
+
prop{L"ReactNative.Composition", L"ThemeResources"};
|
|
535
|
+
return prop;
|
|
536
|
+
}
|
|
537
|
+
|
|
529
538
|
winrt::Microsoft::ReactNative::Composition::Theme Theme::EmptyTheme() noexcept {
|
|
530
539
|
static winrt::Microsoft::ReactNative::Composition::Theme s_emptyTheme{nullptr};
|
|
531
540
|
if (!s_emptyTheme) {
|
|
@@ -537,14 +546,28 @@ winrt::Microsoft::ReactNative::Composition::Theme Theme::EmptyTheme() noexcept {
|
|
|
537
546
|
/*static*/ winrt::Microsoft::ReactNative::Composition::Theme Theme::GetDefaultTheme(
|
|
538
547
|
const winrt::Microsoft::ReactNative::IReactContext &context) noexcept {
|
|
539
548
|
return winrt::Microsoft::ReactNative::ReactPropertyBag(context.Properties())
|
|
540
|
-
.GetOrCreate(ThemePropertyId(), [context]() {
|
|
549
|
+
.GetOrCreate(ThemePropertyId(), [context]() {
|
|
550
|
+
return winrt::make<Theme>(
|
|
551
|
+
context,
|
|
552
|
+
winrt::Microsoft::ReactNative::ReactPropertyBag(context.Properties()).Get(ThemeResourcesPropertyId()));
|
|
553
|
+
});
|
|
541
554
|
}
|
|
542
555
|
|
|
543
|
-
/*static*/ void Theme::
|
|
556
|
+
/*static*/ void Theme::SetDefaultResources(
|
|
544
557
|
const winrt::Microsoft::ReactNative::ReactInstanceSettings &settings,
|
|
545
|
-
const winrt::Microsoft::ReactNative::Composition::
|
|
546
|
-
winrt::Microsoft::ReactNative::ReactPropertyBag(settings.Properties())
|
|
547
|
-
|
|
558
|
+
const winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader &resources) noexcept {
|
|
559
|
+
winrt::Microsoft::ReactNative::ReactPropertyBag properties(settings.Properties());
|
|
560
|
+
properties.Set(ThemeResourcesPropertyId(), resources);
|
|
561
|
+
// If a default theme has already been created - we need to update it with the new resources
|
|
562
|
+
if (auto theme = properties.Get(ThemePropertyId())) {
|
|
563
|
+
winrt::get_self<Theme>(theme)->UpdateCustomResources(resources);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
void Theme::UpdateCustomResources(
|
|
568
|
+
const winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader &resources) noexcept {
|
|
569
|
+
m_customResourceLoader = resources;
|
|
570
|
+
ClearCacheAndRaiseChangedEvent();
|
|
548
571
|
}
|
|
549
572
|
|
|
550
573
|
IReactPropertyNamespace ThemeNamespace() noexcept {
|
|
@@ -552,9 +575,4 @@ IReactPropertyNamespace ThemeNamespace() noexcept {
|
|
|
552
575
|
return value;
|
|
553
576
|
}
|
|
554
577
|
|
|
555
|
-
/*static*/ IReactPropertyName Theme::ThemeChangedEventName() noexcept {
|
|
556
|
-
static IReactPropertyName propName = ReactPropertyBagHelper::GetName(ThemeNamespace(), L"Changed");
|
|
557
|
-
return propName;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
578
|
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|
|
@@ -50,12 +50,13 @@ struct Theme : ThemeT<Theme, Experimental::IInternalTheme> {
|
|
|
50
50
|
|
|
51
51
|
static winrt::Microsoft::ReactNative::Composition::Theme GetDefaultTheme(
|
|
52
52
|
const winrt::Microsoft::ReactNative::IReactContext &context) noexcept;
|
|
53
|
-
static void
|
|
53
|
+
static void SetDefaultResources(
|
|
54
54
|
const winrt::Microsoft::ReactNative::ReactInstanceSettings &settings,
|
|
55
|
-
const winrt::Microsoft::ReactNative::Composition::
|
|
56
|
-
static winrt::Microsoft::ReactNative::IReactPropertyName ThemeChangedEventName() noexcept;
|
|
55
|
+
const winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader &resources) noexcept;
|
|
57
56
|
|
|
58
57
|
private:
|
|
58
|
+
void UpdateCustomResources(
|
|
59
|
+
const winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader &resources) noexcept;
|
|
59
60
|
bool TryGetPlatformColor(const std::string &platformColor, winrt::Windows::UI::Color &color) noexcept;
|
|
60
61
|
void ClearCacheAndRaiseChangedEvent() noexcept;
|
|
61
62
|
|
|
@@ -74,12 +74,8 @@ winrt::Microsoft::ReactNative::Composition::Theme Theme::EmptyTheme() noexcept {
|
|
|
74
74
|
return nullptr;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
/*static*/ void Theme::
|
|
77
|
+
/*static*/ void Theme::SetDefaultResources(
|
|
78
78
|
const winrt::Microsoft::ReactNative::ReactInstanceSettings &,
|
|
79
|
-
const winrt::Microsoft::ReactNative::Composition::
|
|
80
|
-
|
|
81
|
-
/*static*/ IReactPropertyName Theme::ThemeChangedEventName() noexcept {
|
|
82
|
-
return nullptr;
|
|
83
|
-
}
|
|
79
|
+
const winrt::Microsoft::ReactNative::Composition::ICustomResourceLoader &) noexcept {}
|
|
84
80
|
|
|
85
81
|
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#include "pch.h"
|
|
5
|
+
#include "UriImageManager.h"
|
|
6
|
+
|
|
7
|
+
#include "Composition.ImageSource.g.h"
|
|
8
|
+
#include "Composition.UriImageManager.g.cpp"
|
|
9
|
+
#include <ReactPropertyBag.h>
|
|
10
|
+
|
|
11
|
+
namespace winrt::Microsoft::ReactNative::Composition::implementation {
|
|
12
|
+
|
|
13
|
+
struct ImageSource : ImageSourceT<ImageSource> {
|
|
14
|
+
ImageSource(const facebook::react::ImageSource &source)
|
|
15
|
+
: m_size({source.size.width, source.size.height}),
|
|
16
|
+
m_scale(source.scale),
|
|
17
|
+
m_uri(::Microsoft::ReactNative::UriTryCreate(winrt::to_hstring(source.uri))) {}
|
|
18
|
+
|
|
19
|
+
winrt::Windows::Foundation::Uri Uri() noexcept {
|
|
20
|
+
return m_uri;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
winrt::Windows::Foundation::Size Size() noexcept {
|
|
24
|
+
return m_size;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
float Scale() noexcept {
|
|
28
|
+
return m_scale;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private:
|
|
32
|
+
const winrt::Windows::Foundation::Uri m_uri;
|
|
33
|
+
const winrt::Windows::Foundation::Size m_size;
|
|
34
|
+
const float m_scale;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
winrt::Microsoft::ReactNative::Composition::ImageSource MakeImageSource(
|
|
38
|
+
const facebook::react::ImageSource &source) noexcept {
|
|
39
|
+
return winrt::make<ImageSource>(source);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static const ReactPropertyId<ReactNonAbiValue<winrt::com_ptr<UriImageManager>>> &UriImageManagerPropertyId() noexcept {
|
|
43
|
+
static const ReactPropertyId<ReactNonAbiValue<winrt::com_ptr<UriImageManager>>> prop{
|
|
44
|
+
L"ReactNative", L"UriImageManager"};
|
|
45
|
+
return prop;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
winrt::com_ptr<UriImageManager> UriImageManager::GetOrCreate(
|
|
49
|
+
const winrt::Microsoft::ReactNative::ReactPropertyBag &properties) noexcept {
|
|
50
|
+
auto uriImageManager =
|
|
51
|
+
winrt::Microsoft::ReactNative::ReactPropertyBag(properties).GetOrCreate(UriImageManagerPropertyId(), []() {
|
|
52
|
+
return winrt::make_self<UriImageManager>();
|
|
53
|
+
});
|
|
54
|
+
return uriImageManager.Value();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void UriImageManager::AddUriImageProvider(
|
|
58
|
+
const winrt::Microsoft::ReactNative::IReactPropertyBag &properties,
|
|
59
|
+
const IUriImageProvider &provider) {
|
|
60
|
+
if (!provider)
|
|
61
|
+
winrt::throw_hresult(E_INVALIDARG);
|
|
62
|
+
GetOrCreate(winrt::Microsoft::ReactNative::ReactPropertyBag(properties))->m_providers.push_back(provider);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
IUriImageProvider UriImageManager::TryGetUriImageProvider(
|
|
66
|
+
const IReactContext &context,
|
|
67
|
+
winrt::Microsoft::ReactNative::Composition::ImageSource &source) noexcept {
|
|
68
|
+
auto uri = source.Uri();
|
|
69
|
+
if (!uri) {
|
|
70
|
+
return nullptr;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
for (auto &provider : m_providers) {
|
|
74
|
+
if (provider.CanLoadImageUri(context, source.Uri())) {
|
|
75
|
+
return provider;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return nullptr;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
#include "Composition.UriImageManager.g.h"
|
|
6
|
+
|
|
7
|
+
#include <ReactPropertyBag.h>
|
|
8
|
+
#include <Utils/ImageUtils.h>
|
|
9
|
+
#include <react/renderer/imagemanager/primitives.h>
|
|
10
|
+
#include <winrt/Microsoft.ReactNative.Composition.h>
|
|
11
|
+
|
|
12
|
+
namespace winrt::Microsoft::ReactNative::Composition::implementation {
|
|
13
|
+
|
|
14
|
+
struct UriImageManager : UriImageManagerT<UriImageManager> {
|
|
15
|
+
UriImageManager() = default;
|
|
16
|
+
|
|
17
|
+
static void AddUriImageProvider(
|
|
18
|
+
const winrt::Microsoft::ReactNative::IReactPropertyBag &properties,
|
|
19
|
+
const IUriImageProvider &provider);
|
|
20
|
+
|
|
21
|
+
static winrt::com_ptr<UriImageManager> GetOrCreate(
|
|
22
|
+
const winrt::Microsoft::ReactNative::ReactPropertyBag &properties) noexcept;
|
|
23
|
+
|
|
24
|
+
IUriImageProvider TryGetUriImageProvider(
|
|
25
|
+
const IReactContext &context,
|
|
26
|
+
winrt::Microsoft::ReactNative::Composition::ImageSource &source) noexcept;
|
|
27
|
+
|
|
28
|
+
private:
|
|
29
|
+
std::vector<IUriImageProvider> m_providers;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
winrt::Microsoft::ReactNative::Composition::ImageSource MakeImageSource(
|
|
33
|
+
const facebook::react::ImageSource &source) noexcept;
|
|
34
|
+
|
|
35
|
+
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|
|
36
|
+
|
|
37
|
+
namespace winrt::Microsoft::ReactNative::Composition::factory_implementation {
|
|
38
|
+
struct UriImageManager : UriImageManagerT<UriImageManager, implementation::UriImageManager> {};
|
|
39
|
+
} // namespace winrt::Microsoft::ReactNative::Composition::factory_implementation
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#include "pch.h"
|
|
5
|
+
|
|
6
|
+
#include "UriImageManager.h"
|
|
7
|
+
|
|
8
|
+
#include "Composition.UriImageManager.g.cpp"
|
|
9
|
+
|
|
10
|
+
namespace winrt::Microsoft::ReactNative::Composition::implementation {
|
|
11
|
+
|
|
12
|
+
void UriImageManager::AddUriImageProvider(
|
|
13
|
+
const winrt::Microsoft::ReactNative::IReactPropertyBag &,
|
|
14
|
+
const IUriImageProvider &) {}
|
|
15
|
+
|
|
16
|
+
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|
|
@@ -330,6 +330,9 @@ void FabricUIManager::initiateTransaction(facebook::react::MountingCoordinator::
|
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
void FabricUIManager::schedulerDidFinishTransaction(
|
|
333
|
+
const facebook::react::MountingCoordinator::Shared &mountingCoordinator) {}
|
|
334
|
+
|
|
335
|
+
void FabricUIManager::schedulerShouldRenderTransactions(
|
|
333
336
|
const facebook::react::MountingCoordinator::Shared &mountingCoordinator) {
|
|
334
337
|
// Should cache this locally
|
|
335
338
|
|
|
@@ -78,6 +78,8 @@ struct FabricUIManager final : public std::enable_shared_from_this<FabricUIManag
|
|
|
78
78
|
std::unordered_map<facebook::react::SurfaceId, SurfaceInfo> m_surfaceRegistry;
|
|
79
79
|
|
|
80
80
|
// Inherited via SchedulerDelegate
|
|
81
|
+
virtual void schedulerShouldRenderTransactions(
|
|
82
|
+
const facebook::react::MountingCoordinator::Shared &mountingCoordinator) override;
|
|
81
83
|
virtual void schedulerDidFinishTransaction(
|
|
82
84
|
const facebook::react::MountingCoordinator::Shared &mountingCoordinator) override;
|
|
83
85
|
virtual void schedulerDidRequestPreliminaryViewAllocation(
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
namespace facebook {
|
|
10
10
|
namespace react {
|
|
11
11
|
|
|
12
|
-
ImageManager::ImageManager(ContextContainer::Shared const &) {
|
|
13
|
-
|
|
12
|
+
ImageManager::ImageManager(ContextContainer::Shared const &contextContainer) {
|
|
13
|
+
auto reactContext = *contextContainer->find<winrt::Microsoft::ReactNative::ReactContext>("MSRN.ReactContext");
|
|
14
|
+
self_ = new Microsoft::ReactNative::WindowsImageManager(reactContext);
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
ImageManager::~ImageManager() {
|