Line data Source code
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 : #ifndef MOZILLA_LAYERS_KNOWSCOMPOSITOR
8 : #define MOZILLA_LAYERS_KNOWSCOMPOSITOR
9 :
10 : #include "mozilla/layers/LayersTypes.h" // for LayersBackend
11 : #include "mozilla/layers/CompositorTypes.h"
12 :
13 : namespace mozilla {
14 : namespace layers {
15 :
16 : class SyncObject;
17 : class TextureForwarder;
18 : class LayersIPCActor;
19 :
20 : /**
21 : * An abstract interface for classes that are tied to a specific Compositor across
22 : * IPDL and uses TextureFactoryIdentifier to describe this Compositor.
23 : */
24 : class KnowsCompositor {
25 : public:
26 : NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
27 :
28 : KnowsCompositor();
29 : ~KnowsCompositor();
30 :
31 : void IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier);
32 :
33 62 : SyncObject* GetSyncObject() { return mSyncObject; }
34 :
35 140 : int32_t GetMaxTextureSize() const
36 : {
37 140 : return mTextureFactoryIdentifier.mMaxTextureSize;
38 : }
39 :
40 : /**
41 : * Returns the type of backend that is used off the main thread.
42 : * We only don't allow changing the backend type at runtime so this value can
43 : * be queried once and will not change until Gecko is restarted.
44 : */
45 130 : LayersBackend GetCompositorBackendType() const
46 : {
47 130 : return mTextureFactoryIdentifier.mParentBackend;
48 : }
49 :
50 : bool SupportsTextureBlitting() const
51 : {
52 : return mTextureFactoryIdentifier.mSupportsTextureBlitting;
53 : }
54 :
55 : bool SupportsPartialUploads() const
56 : {
57 : return mTextureFactoryIdentifier.mSupportsPartialUploads;
58 : }
59 :
60 0 : bool SupportsComponentAlpha() const
61 : {
62 0 : return mTextureFactoryIdentifier.mSupportsComponentAlpha;
63 : }
64 :
65 : bool GetCompositorUseANGLE() const
66 : {
67 : return mTextureFactoryIdentifier.mCompositorUseANGLE;
68 : }
69 :
70 1 : const TextureFactoryIdentifier& GetTextureFactoryIdentifier() const
71 : {
72 1 : return mTextureFactoryIdentifier;
73 : }
74 :
75 4 : bool DeviceCanReset() const {
76 4 : return GetCompositorBackendType() != LayersBackend::LAYERS_BASIC;
77 : }
78 :
79 0 : int32_t GetSerial() { return mSerial; }
80 :
81 : /**
82 : * Helpers for finding other related interface. These are infallible.
83 : */
84 : virtual TextureForwarder* GetTextureForwarder() = 0;
85 : virtual LayersIPCActor* GetLayersIPCActor() = 0;
86 :
87 : protected:
88 : TextureFactoryIdentifier mTextureFactoryIdentifier;
89 : RefPtr<SyncObject> mSyncObject;
90 :
91 : const int32_t mSerial;
92 : static mozilla::Atomic<int32_t> sSerialCounter;
93 : };
94 :
95 : } // namespace layers
96 : } // namespace mozilla
97 :
98 : #endif
|