mirror of
https://github.com/SFML/SFML.git
synced 2025-03-14 01:40:05 +08:00
Apply const to more local variables
This commit is contained in:
parent
819bdb67e9
commit
0e17f4d320
@ -407,7 +407,7 @@ bool RenderTarget::setActive(bool active)
|
||||
|
||||
using RenderTargetImpl::getContextRenderTargetMap;
|
||||
auto& contextRenderTargetMap = getContextRenderTargetMap();
|
||||
auto it = contextRenderTargetMap.find(contextId);
|
||||
const auto it = contextRenderTargetMap.find(contextId);
|
||||
|
||||
if (active)
|
||||
{
|
||||
|
@ -510,7 +510,7 @@ bool RenderTextureImplFBO::activate(bool active)
|
||||
|
||||
if (it != m_multisampleFrameBuffers.end())
|
||||
{
|
||||
auto frameBuffer = it->second.lock();
|
||||
const auto frameBuffer = it->second.lock();
|
||||
|
||||
if (frameBuffer)
|
||||
{
|
||||
@ -526,7 +526,7 @@ bool RenderTextureImplFBO::activate(bool active)
|
||||
|
||||
if (it != m_frameBuffers.end())
|
||||
{
|
||||
auto frameBuffer = it->second.lock();
|
||||
const auto frameBuffer = it->second.lock();
|
||||
|
||||
if (frameBuffer)
|
||||
{
|
||||
@ -568,8 +568,8 @@ void RenderTextureImplFBO::updateTexture(unsigned int)
|
||||
|
||||
if ((frameBufferIt != m_frameBuffers.end()) && (multisampleIt != m_multisampleFrameBuffers.end()))
|
||||
{
|
||||
auto frameBuffer = frameBufferIt->second.lock();
|
||||
auto multiSampleFrameBuffer = multisampleIt->second.lock();
|
||||
const auto frameBuffer = frameBufferIt->second.lock();
|
||||
const auto multiSampleFrameBuffer = multisampleIt->second.lock();
|
||||
|
||||
if (frameBuffer && multiSampleFrameBuffer)
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ ActivityStates* retrieveStates(ANativeActivity* activity)
|
||||
static void initializeMain(ActivityStates* states)
|
||||
{
|
||||
// Protect from concurrent access
|
||||
std::lock_guard lock(states->mutex);
|
||||
const std::lock_guard lock(states->mutex);
|
||||
|
||||
// Prepare and share the looper to be read later
|
||||
ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
|
||||
@ -117,7 +117,7 @@ static void initializeMain(ActivityStates* states)
|
||||
static void terminateMain(ActivityStates* states)
|
||||
{
|
||||
// Protect from concurrent access
|
||||
std::lock_guard lock(states->mutex);
|
||||
const std::lock_guard lock(states->mutex);
|
||||
|
||||
// The main thread has finished, we must explicitly ask the activity to finish
|
||||
states->mainOver = true;
|
||||
@ -138,7 +138,7 @@ void* main(ActivityStates* states)
|
||||
terminateMain(states);
|
||||
|
||||
{
|
||||
std::lock_guard lock(states->mutex);
|
||||
const std::lock_guard lock(states->mutex);
|
||||
|
||||
states->terminated = true;
|
||||
}
|
||||
@ -260,7 +260,7 @@ static void onResume(ANativeActivity* activity)
|
||||
{
|
||||
// Retrieve our activity states from the activity instance
|
||||
sf::priv::ActivityStates* states = sf::priv::retrieveStates(activity);
|
||||
std::lock_guard lock(states->mutex);
|
||||
const std::lock_guard lock(states->mutex);
|
||||
|
||||
if (states->fullscreen)
|
||||
goToFullscreenMode(activity);
|
||||
@ -278,7 +278,7 @@ static void onPause(ANativeActivity* activity)
|
||||
{
|
||||
// Retrieve our activity states from the activity instance
|
||||
sf::priv::ActivityStates* states = sf::priv::retrieveStates(activity);
|
||||
std::lock_guard lock(states->mutex);
|
||||
const std::lock_guard lock(states->mutex);
|
||||
|
||||
// Send an event to warn people the activity has been paused
|
||||
sf::Event event;
|
||||
@ -302,7 +302,7 @@ static void onDestroy(ANativeActivity* activity)
|
||||
|
||||
// Send an event to warn people the activity is being destroyed
|
||||
{
|
||||
std::lock_guard lock(states->mutex);
|
||||
const std::lock_guard lock(states->mutex);
|
||||
|
||||
// If the main thread hasn't yet finished, send the event and wait for
|
||||
// it to finish.
|
||||
@ -344,7 +344,7 @@ static void onDestroy(ANativeActivity* activity)
|
||||
static void onNativeWindowCreated(ANativeActivity* activity, ANativeWindow* window)
|
||||
{
|
||||
sf::priv::ActivityStates* states = sf::priv::retrieveStates(activity);
|
||||
std::lock_guard lock(states->mutex);
|
||||
const std::lock_guard lock(states->mutex);
|
||||
|
||||
// Update the activity states
|
||||
states->window = window;
|
||||
@ -369,7 +369,7 @@ static void onNativeWindowCreated(ANativeActivity* activity, ANativeWindow* wind
|
||||
static void onNativeWindowDestroyed(ANativeActivity* activity, ANativeWindow* /* window */)
|
||||
{
|
||||
sf::priv::ActivityStates* states = sf::priv::retrieveStates(activity);
|
||||
std::lock_guard lock(states->mutex);
|
||||
const std::lock_guard lock(states->mutex);
|
||||
|
||||
// Update the activity states
|
||||
states->window = nullptr;
|
||||
@ -410,7 +410,7 @@ static void onInputQueueCreated(ANativeActivity* activity, AInputQueue* queue)
|
||||
|
||||
// Attach the input queue
|
||||
{
|
||||
std::lock_guard lock(states->mutex);
|
||||
const std::lock_guard lock(states->mutex);
|
||||
|
||||
AInputQueue_attachLooper(queue, states->looper, 1, states->processEvent, nullptr);
|
||||
states->inputQueue = queue;
|
||||
@ -426,7 +426,7 @@ static void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue)
|
||||
|
||||
// Detach the input queue
|
||||
{
|
||||
std::lock_guard lock(states->mutex);
|
||||
const std::lock_guard lock(states->mutex);
|
||||
|
||||
AInputQueue_detachLooper(queue);
|
||||
states->inputQueue = nullptr;
|
||||
@ -447,7 +447,7 @@ static void onContentRectChanged(ANativeActivity* activity, const ARect* /* rect
|
||||
{
|
||||
// Retrieve our activity states from the activity instance
|
||||
sf::priv::ActivityStates* states = sf::priv::retrieveStates(activity);
|
||||
std::lock_guard lock(states->mutex);
|
||||
const std::lock_guard lock(states->mutex);
|
||||
|
||||
// Make sure the window still exists before we access the dimensions on it
|
||||
if (states->window != nullptr)
|
||||
|
@ -39,7 +39,7 @@ namespace sf::priv
|
||||
ResourceStream::ResourceStream(const std::filesystem::path& filename)
|
||||
{
|
||||
ActivityStates& states = getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
m_file.reset(AAssetManager_open(states.activity->assetManager, filename.c_str(), AASSET_MODE_UNKNOWN));
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ void setVirtualKeyboardVisible(bool visible)
|
||||
// todo: Check if the window is active
|
||||
|
||||
ActivityStates& states = getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
|
||||
// Initializes JNI
|
||||
jint lFlags = 0;
|
||||
@ -169,7 +169,7 @@ bool isMouseButtonPressed(Mouse::Button button)
|
||||
ALooper_pollAll(0, nullptr, nullptr, nullptr);
|
||||
|
||||
ActivityStates& states = getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
|
||||
return states.isButtonPressed[button];
|
||||
}
|
||||
@ -181,7 +181,7 @@ Vector2i getMousePosition()
|
||||
ALooper_pollAll(0, nullptr, nullptr, nullptr);
|
||||
|
||||
ActivityStates& states = getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
|
||||
return states.mousePosition;
|
||||
}
|
||||
@ -214,7 +214,7 @@ bool isTouchDown(unsigned int finger)
|
||||
ALooper_pollAll(0, nullptr, nullptr, nullptr);
|
||||
|
||||
ActivityStates& states = getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
|
||||
return states.touchEvents.find(static_cast<int>(finger)) != states.touchEvents.end();
|
||||
}
|
||||
@ -226,7 +226,7 @@ Vector2i getTouchPosition(unsigned int finger)
|
||||
ALooper_pollAll(0, nullptr, nullptr, nullptr);
|
||||
|
||||
ActivityStates& states = getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
|
||||
return states.touchEvents.find(static_cast<int>(finger))->second;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ VideoMode VideoModeImpl::getDesktopMode()
|
||||
{
|
||||
// Get the activity states
|
||||
priv::ActivityStates& states = priv::getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
|
||||
return VideoMode(Vector2u(states.screenSize));
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ WindowImplAndroid::WindowImplAndroid(VideoMode mode,
|
||||
m_size(mode.size)
|
||||
{
|
||||
ActivityStates& states = getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
|
||||
if (style & Style::Fullscreen)
|
||||
states.fullscreen = true;
|
||||
@ -90,7 +90,7 @@ WindowImplAndroid::~WindowImplAndroid()
|
||||
WindowHandle WindowImplAndroid::getNativeHandle() const
|
||||
{
|
||||
ActivityStates& states = getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
|
||||
return states.window;
|
||||
}
|
||||
@ -103,7 +103,7 @@ void WindowImplAndroid::processEvents()
|
||||
ALooper_pollAll(0, nullptr, nullptr, nullptr);
|
||||
|
||||
ActivityStates& states = getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
|
||||
if (m_windowBeingCreated)
|
||||
{
|
||||
@ -255,7 +255,7 @@ void WindowImplAndroid::forwardEvent(const Event& event)
|
||||
int WindowImplAndroid::processEvent(int /* fd */, int /* events */, void* /* data */)
|
||||
{
|
||||
ActivityStates& states = getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
|
||||
AInputEvent* inputEvent = nullptr;
|
||||
|
||||
@ -709,7 +709,7 @@ int WindowImplAndroid::getUnicode(AInputEvent* event)
|
||||
{
|
||||
// Retrieve activity states
|
||||
ActivityStates& states = getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
|
||||
// Initializes JNI
|
||||
jint lResult;
|
||||
|
@ -63,7 +63,7 @@ EGLDisplay getInitializedDisplay()
|
||||
|
||||
// On Android, its native activity handles this for us
|
||||
sf::priv::ActivityStates& states = sf::priv::getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
|
||||
return states.display;
|
||||
|
||||
@ -147,7 +147,7 @@ EglContext::EglContext(EglContext* shared,
|
||||
|
||||
// On Android, we must save the created context
|
||||
ActivityStates& states = getActivity();
|
||||
std::lock_guard lock(states.mutex);
|
||||
const std::lock_guard lock(states.mutex);
|
||||
|
||||
states.context = this;
|
||||
|
||||
|
@ -479,7 +479,7 @@ std::shared_ptr<void> GlContext::getSharedContext()
|
||||
void GlContext::registerUnsharedGlObject(std::shared_ptr<void> object)
|
||||
{
|
||||
if (const std::lock_guard lock(Impl::getUnsharedGlObjectsMutex());
|
||||
auto unsharedGlObjects = Impl::getWeakUnsharedGlObjects().lock())
|
||||
const auto unsharedGlObjects = Impl::getWeakUnsharedGlObjects().lock())
|
||||
unsharedGlObjects->emplace_back(Impl::UnsharedGlObject{GlContextImpl::CurrentContext::get().id, std::move(object)});
|
||||
}
|
||||
|
||||
@ -488,12 +488,12 @@ void GlContext::registerUnsharedGlObject(std::shared_ptr<void> object)
|
||||
void GlContext::unregisterUnsharedGlObject(std::shared_ptr<void> object)
|
||||
{
|
||||
if (const std::lock_guard lock(Impl::getUnsharedGlObjectsMutex());
|
||||
auto unsharedGlObjects = Impl::getWeakUnsharedGlObjects().lock())
|
||||
const auto unsharedGlObjects = Impl::getWeakUnsharedGlObjects().lock())
|
||||
{
|
||||
// Find the object in unshared objects and remove it if its associated context is currently active
|
||||
// This will trigger the destructor of the object since shared_ptr
|
||||
// in unshared objects should be the only one existing
|
||||
auto iter = std::find_if(unsharedGlObjects->begin(),
|
||||
const auto iter = std::find_if(unsharedGlObjects->begin(),
|
||||
unsharedGlObjects->end(),
|
||||
[&](const Impl::UnsharedGlObject& obj) {
|
||||
return (obj.object == object) &&
|
||||
@ -555,7 +555,7 @@ void GlContext::releaseTransientContext()
|
||||
std::unique_ptr<GlContext> GlContext::create()
|
||||
{
|
||||
// Make sure that there's an active context (context creation may need extensions, and thus a valid context)
|
||||
auto sharedContext = SharedContext::get();
|
||||
const auto sharedContext = SharedContext::get();
|
||||
|
||||
const std::lock_guard lock(sharedContext->mutex);
|
||||
|
||||
@ -581,7 +581,7 @@ std::unique_ptr<GlContext> GlContext::create()
|
||||
std::unique_ptr<GlContext> GlContext::create(const ContextSettings& settings, const WindowImpl& owner, unsigned int bitsPerPixel)
|
||||
{
|
||||
// Make sure that there's an active context (context creation may need extensions, and thus a valid context)
|
||||
auto sharedContext = SharedContext::get();
|
||||
const auto sharedContext = SharedContext::get();
|
||||
|
||||
const std::lock_guard lock(sharedContext->mutex);
|
||||
|
||||
@ -625,7 +625,7 @@ std::unique_ptr<GlContext> GlContext::create(const ContextSettings& settings, co
|
||||
std::unique_ptr<GlContext> GlContext::create(const ContextSettings& settings, const Vector2u& size)
|
||||
{
|
||||
// Make sure that there's an active context (context creation may need extensions, and thus a valid context)
|
||||
auto sharedContext = SharedContext::get();
|
||||
const auto sharedContext = SharedContext::get();
|
||||
|
||||
const std::lock_guard lock(sharedContext->mutex);
|
||||
|
||||
@ -646,15 +646,13 @@ std::unique_ptr<GlContext> GlContext::create(const ContextSettings& settings, co
|
||||
sharedContext->loadExtensions();
|
||||
}
|
||||
|
||||
std::unique_ptr<GlContext> context;
|
||||
|
||||
// We don't use acquireTransientContext here since we have
|
||||
// to ensure we have exclusive access to the shared context
|
||||
// in order to make sure it is not active during context creation
|
||||
sharedContext->context->setActive(true);
|
||||
|
||||
// Create the context
|
||||
context = std::make_unique<ContextType>(&sharedContext->context.value(), settings, size);
|
||||
auto context = std::make_unique<ContextType>(&sharedContext->context.value(), settings, size);
|
||||
|
||||
sharedContext->context->setActive(false);
|
||||
|
||||
|
@ -868,7 +868,7 @@ void HIDInputManager::buildMappings()
|
||||
UniChar string[maxLength];
|
||||
UniCharCount length = 0;
|
||||
std::uint32_t deadKeyState = 0; // unused value
|
||||
std::uint32_t const modifiers = 0x100; // no modifiers
|
||||
const std::uint32_t modifiers = 0x100; // no modifiers
|
||||
|
||||
// Use current layout for translation
|
||||
const OSStatus error = UCKeyTranslate(layout,
|
||||
|
Loading…
x
Reference in New Issue
Block a user