Skip to content

Commit a0db419

Browse files
committed
Minor style fixes
1 parent 71efaf4 commit a0db419

File tree

3 files changed

+42
-60
lines changed

3 files changed

+42
-60
lines changed

Plugins/NativeEngine/Source/NativeEngine.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,6 @@ namespace Babylon
19331933
{
19341934
m_updateToken.emplace(m_update.GetUpdateToken());
19351935

1936-
// TODO: is there an issue with this?
19371936
m_runtimeScheduler.Get()([this]() {
19381937
m_updateToken.reset();
19391938
});

Plugins/NativeInput/Source/Shared/NativeInput.cpp

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,9 @@ namespace Babylon::Plugins
153153
void NativeInput::Impl::PointerDown(uint32_t pointerId, uint32_t buttonIndex, int32_t x, int32_t y, DeviceType deviceType)
154154
{
155155
m_runtime.Dispatch([pointerId, buttonIndex, x, y, deviceType, this](auto) {
156-
const uint32_t inputIndex{ GetPointerButtonInputIndex(buttonIndex) };
157-
std::vector<int32_t>& deviceInputs{ GetOrCreateInputMap(deviceType, pointerId, {
158-
inputIndex,
159-
POINTER_X_INPUT_INDEX,
160-
POINTER_Y_INPUT_INDEX,
161-
POINTER_DELTA_HORIZONTAL_INDEX,
162-
POINTER_DELTA_VERTICAL_INDEX
163-
})};
156+
const uint32_t inputIndex{GetPointerButtonInputIndex(buttonIndex)};
157+
std::vector<int32_t>& deviceInputs{GetOrCreateInputMap(deviceType, pointerId,
158+
{inputIndex, POINTER_X_INPUT_INDEX, POINTER_Y_INPUT_INDEX, POINTER_DELTA_HORIZONTAL_INDEX, POINTER_DELTA_VERTICAL_INDEX})};
164159

165160
// Record the x/y, but don't raise associated events (this matches the behavior in the browser).
166161
SetInputState(deviceType, pointerId, POINTER_DELTA_HORIZONTAL_INDEX, 0, deviceInputs, false);
@@ -176,14 +171,9 @@ namespace Babylon::Plugins
176171
void NativeInput::Impl::PointerUp(uint32_t pointerId, uint32_t buttonIndex, int32_t x, int32_t y, DeviceType deviceType)
177172
{
178173
m_runtime.Dispatch([pointerId, buttonIndex, x, y, deviceType, this](auto) {
179-
const uint32_t inputIndex{ GetPointerButtonInputIndex(buttonIndex) };
180-
std::vector<int32_t>& deviceInputs{ GetOrCreateInputMap(deviceType, pointerId, {
181-
inputIndex,
182-
POINTER_X_INPUT_INDEX,
183-
POINTER_Y_INPUT_INDEX,
184-
POINTER_DELTA_HORIZONTAL_INDEX,
185-
POINTER_DELTA_VERTICAL_INDEX
186-
})};
174+
const uint32_t inputIndex{GetPointerButtonInputIndex(buttonIndex)};
175+
std::vector<int32_t>& deviceInputs{GetOrCreateInputMap(deviceType, pointerId,
176+
{inputIndex, POINTER_X_INPUT_INDEX, POINTER_Y_INPUT_INDEX, POINTER_DELTA_HORIZONTAL_INDEX, POINTER_DELTA_VERTICAL_INDEX})};
187177

188178
// Record the x/y, but don't raise associated events (this matches the behavior in the browser).
189179
SetInputState(deviceType, pointerId, POINTER_DELTA_HORIZONTAL_INDEX, 0, deviceInputs, false);
@@ -208,13 +198,8 @@ namespace Babylon::Plugins
208198
void NativeInput::Impl::PointerMove(uint32_t pointerId, int32_t x, int32_t y, DeviceType deviceType)
209199
{
210200
m_runtime.Dispatch([pointerId, x, y, deviceType, this](auto) {
211-
std::vector<int32_t>& deviceInputs{GetOrCreateInputMap(deviceType, pointerId, {
212-
POINTER_X_INPUT_INDEX,
213-
POINTER_Y_INPUT_INDEX,
214-
POINTER_DELTA_HORIZONTAL_INDEX,
215-
POINTER_DELTA_VERTICAL_INDEX,
216-
POINTER_MOVE_INDEX
217-
})};
201+
std::vector<int32_t>& deviceInputs{GetOrCreateInputMap(deviceType, pointerId,
202+
{POINTER_X_INPUT_INDEX, POINTER_Y_INPUT_INDEX, POINTER_DELTA_HORIZONTAL_INDEX, POINTER_DELTA_VERTICAL_INDEX, POINTER_MOVE_INDEX})};
218203
int32_t deltaX = 0;
219204
int32_t deltaY = 0;
220205

@@ -245,8 +230,7 @@ namespace Babylon::Plugins
245230

246231
void NativeInput::Impl::PointerScroll(uint32_t pointerId, uint32_t scrollAxis, int32_t scrollValue, DeviceType deviceType)
247232
{
248-
m_runtime.Dispatch([pointerId, scrollAxis, scrollValue, deviceType, this](auto)
249-
{
233+
m_runtime.Dispatch([pointerId, scrollAxis, scrollValue, deviceType, this](auto) {
250234
std::vector<int32_t>& deviceInputs{GetOrCreateInputMap(deviceType, pointerId, {scrollAxis})};
251235
SetInputState(deviceType, pointerId, scrollAxis, scrollValue, deviceInputs, true);
252236

Polyfills/Canvas/Source/Image.cpp

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -108,40 +108,39 @@ namespace Babylon::Polyfills::Internal
108108
request.ResponseType(UrlLib::UrlResponseType::Buffer);
109109
request.SendAsync()
110110
.then(m_runtimeScheduler.Get(), m_cancellationSource,
111-
[this, thisRef = Napi::Persistent(info.This()), request](arcana::expected<void, std::exception_ptr> result)
112-
{
113-
if (result.has_error())
114-
{
115-
HandleLoadImageError(Napi::Error::New(thisRef.Env(), result.error()));
116-
return;
117-
}
118-
119-
Dispose();
120-
121-
auto buffer = request.ResponseBuffer();
122-
if (buffer.data() == nullptr || buffer.size_bytes() == 0)
123-
{
124-
HandleLoadImageError(Napi::Error::New(thisRef.Env(), "Image with provided source returned empty response."));
125-
return;
126-
}
127-
128-
bx::AllocatorI* allocator = &Graphics::DeviceContext::GetFromJavaScript(thisRef.Env()).Allocator();
129-
m_imageContainer = bimg::imageParse(allocator, buffer.data(), static_cast<uint32_t>(buffer.size_bytes()), bimg::TextureFormat::RGBA8);
130-
131-
if (m_imageContainer == nullptr)
132-
{
133-
HandleLoadImageError(Napi::Error::New(thisRef.Env(), "Unable to decode image with provided src."));
134-
return;
135-
}
136-
137-
m_width = m_imageContainer->m_width;
138-
m_height = m_imageContainer->m_height;
139-
140-
if (!m_onloadHandlerRef.IsEmpty())
141-
{
142-
m_onloadHandlerRef.Call({});
143-
}
144-
});
111+
[this, thisRef = Napi::Persistent(info.This()), request](arcana::expected<void, std::exception_ptr> result) {
112+
if (result.has_error())
113+
{
114+
HandleLoadImageError(Napi::Error::New(Env(), result.error()));
115+
return;
116+
}
117+
118+
Dispose();
119+
120+
auto buffer = request.ResponseBuffer();
121+
if (buffer.data() == nullptr || buffer.size_bytes() == 0)
122+
{
123+
HandleLoadImageError(Napi::Error::New(Env(), "Image with provided source returned empty response."));
124+
return;
125+
}
126+
127+
bx::AllocatorI* allocator = &Graphics::DeviceContext::GetFromJavaScript(thisRef.Env()).Allocator();
128+
m_imageContainer = bimg::imageParse(allocator, buffer.data(), static_cast<uint32_t>(buffer.size_bytes()), bimg::TextureFormat::RGBA8);
129+
130+
if (m_imageContainer == nullptr)
131+
{
132+
HandleLoadImageError(Napi::Error::New(Env(), "Unable to decode image with provided src."));
133+
return;
134+
}
135+
136+
m_width = m_imageContainer->m_width;
137+
m_height = m_imageContainer->m_height;
138+
139+
if (!m_onloadHandlerRef.IsEmpty())
140+
{
141+
m_onloadHandlerRef.Call({});
142+
}
143+
});
145144
}
146145

147146
void NativeCanvasImage::SetOnload(const Napi::CallbackInfo&, const Napi::Value& value)

0 commit comments

Comments
 (0)