コード例 #1
0
ファイル: obs-hotkey.c プロジェクト: Bl00drav3n/obs-studio
void obs_hotkey_unregister(obs_hotkey_id id)
{
	if (!lock())
		return;
	if (unregister_hotkey(id))
		fixup_pointers();
	unlock();
}
コード例 #2
0
ファイル: obs-hotkey.c プロジェクト: Bl00drav3n/obs-studio
static void context_release_hotkeys(struct obs_context_data *context)
{
	if (!context->hotkeys.num)
		goto cleanup;

	bool need_fixup = false;
	for (size_t i = 0; i < context->hotkeys.num; i++)
		need_fixup = unregister_hotkey(context->hotkeys.array[i]) ||
			need_fixup;

	if (need_fixup)
		fixup_pointers();

cleanup:
	da_free(context->hotkeys);
}
コード例 #3
0
ファイル: obs-hotkey.c プロジェクト: Bl00drav3n/obs-studio
static inline bool unregister_hotkey_pair(obs_hotkey_pair_id id)
{
	if (id >= obs->hotkeys.next_pair_id)
		return false;

	size_t idx;
	if (!find_pair_id(id, &idx))
		return false;

	obs_hotkey_pair_t *pair = &obs->hotkeys.hotkey_pairs.array[idx];

	bool need_fixup = unregister_hotkey(pair->id[0]);
	need_fixup = unregister_hotkey(pair->id[1]) || need_fixup;
	if (need_fixup)
		fixup_pointers();

	da_erase(obs->hotkeys.hotkey_pairs, idx);
	return obs->hotkeys.hotkey_pairs.num >= idx;
}
コード例 #4
0
ファイル: BenchSpriteSort.cpp プロジェクト: OpenRCT2/OpenRCT2
// This function is based on benchgfx_render_screenshots
static void BM_paint_session_arrange(benchmark::State& state, const std::vector<paint_session> inputSessions)
{
    std::vector<paint_session> sessions = inputSessions;
    // Fixing up the pointers continuously is wasteful. Fix it up once for `sessions` and store a copy.
    // Keep in mind we need bit-exact copy, as the lists use pointers.
    // Once sorted, just restore the copy with the original fixed-up version.
    paint_session* local_s = new paint_session[std::size(sessions)];
    fixup_pointers(&sessions[0], std::size(sessions), std::size(local_s->PaintStructs), std::size(local_s->Quadrants));
    std::copy_n(sessions.cbegin(), std::size(sessions), local_s);
    for (auto _ : state)
    {
        state.PauseTiming();
        std::copy_n(local_s, std::size(sessions), sessions.begin());
        state.ResumeTiming();
        paint_session_arrange(&sessions[0]);
        benchmark::DoNotOptimize(sessions);
    }
    state.SetItemsProcessed(state.iterations() * std::size(sessions));
    delete[] local_s;
}
コード例 #5
0
ファイル: obs-hotkey.c プロジェクト: Bl00drav3n/obs-studio
static inline obs_hotkey_id obs_hotkey_register_internal(
		obs_hotkey_registerer_t type, void *registerer,
		struct obs_context_data *context,
		const char *name, const char *description,
		obs_hotkey_func func, void *data)
{
	if ((obs->hotkeys.next_id + 1) == OBS_INVALID_HOTKEY_ID)
		blog(LOG_WARNING, "obs-hotkey: Available hotkey ids exhausted");

	obs_hotkey_t *base_addr = obs->hotkeys.hotkeys.array;
	obs_hotkey_id result    = obs->hotkeys.next_id++;
	obs_hotkey_t *hotkey    = da_push_back_new(obs->hotkeys.hotkeys);

	hotkey->id              = result;
	hotkey->name            = bstrdup(name);
	hotkey->description     = bstrdup(description);
	hotkey->func            = func;
	hotkey->data            = data;
	hotkey->registerer_type = type;
	hotkey->registerer      = registerer;
	hotkey->pair_partner_id = OBS_INVALID_HOTKEY_PAIR_ID;

	if (context) {
		obs_data_array_t *data =
			obs_data_get_array(context->hotkey_data, name);
		load_bindings(hotkey, data);
		obs_data_array_release(data);

		context_add_hotkey(context, result);
	}

	if (base_addr != obs->hotkeys.hotkeys.array)
		fixup_pointers();

	hotkey_signal("hotkey_register", hotkey);

	return result;
}