LayersTypes.cpp (3058B)
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/. */ 6 7 #include "LayersTypes.h" 8 9 #include <cinttypes> 10 #include "nsPrintfCString.h" 11 #include "mozilla/gfx/gfxVars.h" 12 13 #ifdef XP_WIN 14 # include "gfxConfig.h" 15 # include "mozilla/StaticPrefs_gfx.h" 16 #endif 17 18 namespace mozilla { 19 namespace layers { 20 21 const char* kCompositionPayloadTypeNames[kCompositionPayloadTypeCount] = { 22 "KeyPress", 23 "APZScroll", 24 "APZPinchZoom", 25 "ContentPaint", 26 "MouseUpFollowedByClick", 27 }; 28 29 const char* GetLayersBackendName(LayersBackend aBackend) { 30 switch (aBackend) { 31 case LayersBackend::LAYERS_NONE: 32 return "none"; 33 case LayersBackend::LAYERS_WR: 34 if (gfx::gfxVars::UseSoftwareWebRender()) { 35 #ifdef XP_WIN 36 if (gfx::gfxVars::AllowSoftwareWebRenderD3D11() && 37 gfx::gfxConfig::IsEnabled(gfx::Feature::D3D11_COMPOSITING)) { 38 return "webrender_software_d3d11"; 39 } 40 #endif 41 return "webrender_software"; 42 } 43 return "webrender"; 44 default: 45 MOZ_ASSERT_UNREACHABLE("unknown layers backend"); 46 return "unknown"; 47 } 48 } 49 50 std::ostream& operator<<(std::ostream& aStream, const LayersId& aId) { 51 return aStream << nsPrintfCString("0x%" PRIx64, aId.mId).get(); 52 } 53 54 /* static */ 55 CompositableHandle CompositableHandle::GetNext() { 56 static std::atomic<uint64_t> sCounter = 0; 57 return CompositableHandle{++sCounter}; 58 } 59 60 /* static */ 61 RemoteTextureId RemoteTextureId::GetNext() { 62 static std::atomic<uint64_t> sCounter = 0; 63 return RemoteTextureId{++sCounter}; 64 } 65 66 /* static */ 67 RemoteTextureOwnerId RemoteTextureOwnerId::GetNext() { 68 static std::atomic<uint64_t> sCounter = 0; 69 return RemoteTextureOwnerId{++sCounter}; 70 } 71 72 /* static */ 73 SurfaceDescriptorRemoteDecoderId SurfaceDescriptorRemoteDecoderId::GetNext() { 74 static std::atomic<uint64_t> sCounter = 0; 75 return SurfaceDescriptorRemoteDecoderId{++sCounter}; 76 } 77 78 /* static */ 79 GpuProcessTextureId GpuProcessTextureId::GetNext() { 80 if (!XRE_IsGPUProcess()) { 81 MOZ_ASSERT_UNREACHABLE("unexpected to be called"); 82 return GpuProcessTextureId{}; 83 } 84 85 static std::atomic<uint64_t> sCounter = 0; 86 return GpuProcessTextureId{++sCounter}; 87 } 88 89 /* static */ 90 CompositeProcessFencesHolderId CompositeProcessFencesHolderId::GetNext() { 91 if (!XRE_IsGPUProcess()) { 92 MOZ_ASSERT_UNREACHABLE("unexpected to be called"); 93 return CompositeProcessFencesHolderId{}; 94 } 95 96 static std::atomic<uint64_t> sCounter = 0; 97 return CompositeProcessFencesHolderId{++sCounter}; 98 } 99 100 std::ostream& operator<<(std::ostream& os, ScrollDirection aDirection) { 101 switch (aDirection) { 102 case ScrollDirection::eHorizontal: 103 os << "horizontal"; 104 break; 105 case ScrollDirection::eVertical: 106 os << "vertical"; 107 break; 108 } 109 return os; 110 } 111 112 } // namespace layers 113 } // namespace mozilla