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"
15 StaticAutoPtr
<GpuProcessD3D11QueryMap
> GpuProcessD3D11QueryMap::sInstance
;
18 void GpuProcessD3D11QueryMap::Init() {
19 MOZ_ASSERT(XRE_IsGPUProcess());
20 sInstance
= new GpuProcessD3D11QueryMap();
24 void GpuProcessD3D11QueryMap::Shutdown() {
25 MOZ_ASSERT(XRE_IsGPUProcess());
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()) {
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()) {
65 } // namespace mozilla