MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / Update

Method Update

TombEngine/Specific/Video/Video.cpp:372–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370 }
371
372 bool VideoHandler::Update()
373 {
374 if (_deInitializing || _player == nullptr)
375 return false;
376
377 // Attempt to map and render texture only if callback has set frame to be rendered.
378 if (_needRender)
379 {
380 auto mappedResource = D3D11_MAPPED_SUBRESOURCE{};
381 if (_videoTexture && SUCCEEDED(_d3dContext->Map(_videoTexture, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource)))
382 {
383 // Copy framebuffer row by row, otherwise skewing may occur.
384 unsigned char* pData = reinterpret_cast<unsigned char*>(mappedResource.pData);
385 for (int row = 0; row < _size.y; row++)
386 memcpy(pData + row * mappedResource.RowPitch, _frameBuffer.data() + row * _size.x * 4, _size.x * 4);
387 _d3dContext->Unmap(_videoTexture, 0);
388
389 if (_playbackMode == VideoPlaybackMode::Exclusive)
390 {
391 RenderExclusive();
392 }
393 else if (_playbackMode == VideoPlaybackMode::Background)
394 {
395 RenderBackground();
396 }
397 }
398 else
399 {
400 TENLog("Failed to render video texture", LogLevel::Error);
401 }
402
403 _needRender = false;
404 }
405
406 if (_playbackMode == VideoPlaybackMode::Exclusive)
407 {
408 UpdateExclusive();
409 }
410 else if (_playbackMode == VideoPlaybackMode::Background)
411 {
412 UpdateBackground();
413 }
414
415 return (_playbackMode == VideoPlaybackMode::Exclusive);
416 }
417
418 void VideoHandler::UpdateExclusive()
419 {

Callers 2

SetPositionMethod · 0.45
SetRotationMethod · 0.45

Calls 3

TENLogFunction · 0.85
MapMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected