2017-10-28 02:10:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2017-06-06 13:28:00 +03:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "LayersTypes.h"
|
|
|
|
|
2020-10-22 22:16:19 +03:00
|
|
|
#include <cinttypes>
|
|
|
|
#include "nsPrintfCString.h"
|
2020-11-21 18:20:34 +03:00
|
|
|
#include "mozilla/gfx/gfxVars.h"
|
2020-10-22 22:16:19 +03:00
|
|
|
|
2021-02-02 18:26:22 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
# include "gfxConfig.h"
|
|
|
|
# include "mozilla/StaticPrefs_gfx.h"
|
|
|
|
#endif
|
|
|
|
|
2017-06-06 13:28:00 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2020-06-30 01:41:20 +03:00
|
|
|
const char* kCompositionPayloadTypeNames[kCompositionPayloadTypeCount] = {
|
|
|
|
"KeyPress",
|
|
|
|
"APZScroll",
|
|
|
|
"APZPinchZoom",
|
|
|
|
"ContentPaint",
|
2021-03-19 23:40:24 +03:00
|
|
|
"MouseUpFollowedByClick",
|
2020-06-30 01:41:20 +03:00
|
|
|
};
|
|
|
|
|
2019-11-26 22:42:06 +03:00
|
|
|
const char* GetLayersBackendName(LayersBackend aBackend) {
|
|
|
|
switch (aBackend) {
|
|
|
|
case LayersBackend::LAYERS_NONE:
|
|
|
|
return "none";
|
|
|
|
case LayersBackend::LAYERS_WR:
|
2021-01-04 17:20:17 +03:00
|
|
|
if (gfx::gfxVars::UseSoftwareWebRender()) {
|
2021-02-02 18:26:22 +03:00
|
|
|
#ifdef XP_WIN
|
2021-03-10 08:22:45 +03:00
|
|
|
if (gfx::gfxVars::AllowSoftwareWebRenderD3D11() &&
|
2021-02-02 18:26:22 +03:00
|
|
|
gfx::gfxConfig::IsEnabled(gfx::Feature::D3D11_COMPOSITING)) {
|
|
|
|
return "webrender_software_d3d11";
|
|
|
|
}
|
|
|
|
#endif
|
2020-11-21 18:20:34 +03:00
|
|
|
return "webrender_software";
|
|
|
|
}
|
2019-11-26 22:42:06 +03:00
|
|
|
return "webrender";
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("unknown layers backend");
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-22 22:16:19 +03:00
|
|
|
std::ostream& operator<<(std::ostream& aStream, const LayersId& aId) {
|
|
|
|
return aStream << nsPrintfCString("0x%" PRIx64, aId.mId).get();
|
|
|
|
}
|
|
|
|
|
2022-06-29 12:32:29 +03:00
|
|
|
/* static */
|
|
|
|
CompositableHandle CompositableHandle::GetNext() {
|
|
|
|
static std::atomic<uint64_t> sCounter = 0;
|
|
|
|
return CompositableHandle{++sCounter};
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
RemoteTextureId RemoteTextureId::GetNext() {
|
|
|
|
static std::atomic<uint64_t> sCounter = 0;
|
|
|
|
return RemoteTextureId{++sCounter};
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
RemoteTextureOwnerId RemoteTextureOwnerId::GetNext() {
|
|
|
|
static std::atomic<uint64_t> sCounter = 0;
|
|
|
|
return RemoteTextureOwnerId{++sCounter};
|
|
|
|
}
|
|
|
|
|
2023-01-19 11:19:28 +03:00
|
|
|
/* static */
|
|
|
|
GpuProcessTextureId GpuProcessTextureId::GetNext() {
|
|
|
|
if (!XRE_IsGPUProcess()) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
|
|
|
|
return GpuProcessTextureId{};
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::atomic<uint64_t> sCounter = 0;
|
|
|
|
return GpuProcessTextureId{++sCounter};
|
|
|
|
}
|
|
|
|
|
2017-06-06 13:28:00 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|