/src/mozilla-central/gfx/layers/mlgpu/TextureSourceProviderMLGPU.cpp
Line | Count | Source (jump to first uncovered line) |
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 "TextureSourceProviderMLGPU.h" |
8 | | #include "LayerManagerMLGPU.h" |
9 | | #include "MLGDevice.h" |
10 | | #ifdef XP_WIN |
11 | | # include "mozilla/layers/MLGDeviceD3D11.h" |
12 | | #endif |
13 | | |
14 | | namespace mozilla { |
15 | | namespace layers { |
16 | | |
17 | | TextureSourceProviderMLGPU::TextureSourceProviderMLGPU(LayerManagerMLGPU* aLayerManager, MLGDevice* aDevice) |
18 | | : mLayerManager(aLayerManager), |
19 | | mDevice(aDevice) |
20 | 0 | { |
21 | 0 | } |
22 | | |
23 | | TextureSourceProviderMLGPU::~TextureSourceProviderMLGPU() |
24 | 0 | { |
25 | 0 | } |
26 | | |
27 | | int32_t |
28 | | TextureSourceProviderMLGPU::GetMaxTextureSize() const |
29 | 0 | { |
30 | 0 | if (!mDevice) { |
31 | 0 | return 0; |
32 | 0 | } |
33 | 0 | return mDevice->GetMaxTextureSize(); |
34 | 0 | } |
35 | | |
36 | | bool |
37 | | TextureSourceProviderMLGPU::SupportsEffect(EffectTypes aEffect) |
38 | 0 | { |
39 | 0 | switch (aEffect) { |
40 | 0 | case EffectTypes::YCBCR: |
41 | 0 | return true; |
42 | 0 | default: |
43 | 0 | MOZ_ASSERT_UNREACHABLE("NYI"); |
44 | 0 | } |
45 | 0 | return false; |
46 | 0 | } |
47 | | |
48 | | bool |
49 | | TextureSourceProviderMLGPU::IsValid() const |
50 | 0 | { |
51 | 0 | return !!mLayerManager; |
52 | 0 | } |
53 | | |
54 | | void |
55 | | TextureSourceProviderMLGPU::Destroy() |
56 | 0 | { |
57 | 0 | mLayerManager = nullptr; |
58 | 0 | mDevice = nullptr; |
59 | 0 | TextureSourceProvider::Destroy(); |
60 | 0 | } |
61 | | |
62 | | #ifdef XP_WIN |
63 | | ID3D11Device* |
64 | | TextureSourceProviderMLGPU::GetD3D11Device() const |
65 | | { |
66 | | if (!mDevice) { |
67 | | return nullptr; |
68 | | } |
69 | | return mDevice->AsD3D11()->GetD3D11Device(); |
70 | | } |
71 | | #endif |
72 | | |
73 | | TimeStamp |
74 | | TextureSourceProviderMLGPU::GetLastCompositionEndTime() const |
75 | 0 | { |
76 | 0 | if (!mLayerManager) { |
77 | 0 | return TimeStamp(); |
78 | 0 | } |
79 | 0 | return mLayerManager->GetLastCompositionEndTime(); |
80 | 0 | } |
81 | | |
82 | | already_AddRefed<DataTextureSource> |
83 | | TextureSourceProviderMLGPU::CreateDataTextureSource(TextureFlags aFlags) |
84 | 0 | { |
85 | 0 | RefPtr<DataTextureSource> texture = mDevice->CreateDataTextureSource(aFlags); |
86 | 0 | return texture.forget(); |
87 | 0 | } |
88 | | |
89 | | already_AddRefed<DataTextureSource> |
90 | | TextureSourceProviderMLGPU::CreateDataTextureSourceAround(gfx::DataSourceSurface* aSurface) |
91 | 0 | { |
92 | 0 | MOZ_ASSERT_UNREACHABLE("NYI"); |
93 | 0 | return nullptr; |
94 | 0 | } |
95 | | |
96 | | void |
97 | | TextureSourceProviderMLGPU::UnlockAfterComposition(TextureHost* aTexture) |
98 | 0 | { |
99 | 0 | TextureSourceProvider::UnlockAfterComposition(aTexture); |
100 | 0 |
|
101 | 0 | // If this is being called after we shutdown the compositor, we must finish |
102 | 0 | // read unlocking now to prevent a cycle. |
103 | 0 | if (!IsValid()) { |
104 | 0 | ReadUnlockTextures(); |
105 | 0 | } |
106 | 0 | } |
107 | | |
108 | | bool |
109 | | TextureSourceProviderMLGPU::NotifyNotUsedAfterComposition(TextureHost* aTextureHost) |
110 | 0 | { |
111 | 0 | if (!IsValid()) { |
112 | 0 | return false; |
113 | 0 | } |
114 | 0 | return TextureSourceProvider::NotifyNotUsedAfterComposition(aTextureHost); |
115 | 0 | } |
116 | | |
117 | | } // namespace layers |
118 | | } // namespace mozilla |