Bug 1919083 - [ci] Enable os-integration variant for more suites, r=jmaher
[gecko.git] / gfx / layers / d3d11 / GpuProcessD3D11QueryMap.cpp
blob524cecc2f379640d75fafe2ae1ae10459ed75006
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "GpuProcessD3D11QueryMap.h"
9 #include "mozilla/webrender/RenderThread.h"
11 namespace mozilla {
13 namespace layers {
15 StaticAutoPtr<GpuProcessD3D11QueryMap> GpuProcessD3D11QueryMap::sInstance;
17 /* static */
18 void GpuProcessD3D11QueryMap::Init() {
19 MOZ_ASSERT(XRE_IsGPUProcess());
20 sInstance = new GpuProcessD3D11QueryMap();
23 /* static */
24 void GpuProcessD3D11QueryMap::Shutdown() {
25 MOZ_ASSERT(XRE_IsGPUProcess());
26 sInstance = nullptr;
29 GpuProcessD3D11QueryMap::GpuProcessD3D11QueryMap()
30 : mMonitor("GpuProcessD3D11QueryMap::mMonitor") {}
32 GpuProcessD3D11QueryMap::~GpuProcessD3D11QueryMap() {}
34 void GpuProcessD3D11QueryMap::Register(GpuProcessQueryId aQueryId,
35 ID3D11Query* aQuery) {
36 MOZ_RELEASE_ASSERT(aQuery);
38 MonitorAutoLock lock(mMonitor);
39 mD3D11QueriesById[aQueryId] = aQuery;
42 void GpuProcessD3D11QueryMap::Unregister(GpuProcessQueryId aQueryId) {
43 MonitorAutoLock lock(mMonitor);
45 auto it = mD3D11QueriesById.find(aQueryId);
46 if (it == mD3D11QueriesById.end()) {
47 return;
49 mD3D11QueriesById.erase(it);
52 RefPtr<ID3D11Query> GpuProcessD3D11QueryMap::GetQuery(
53 GpuProcessQueryId aQueryId) {
54 MonitorAutoLock lock(mMonitor);
56 auto it = mD3D11QueriesById.find(aQueryId);
57 if (it == mD3D11QueriesById.end()) {
58 return nullptr;
61 return it->second;
64 } // namespace layers
65 } // namespace mozilla