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 #ifndef MOZILLA_GFX_BUFFERHOST_H
8 #define MOZILLA_GFX_BUFFERHOST_H
10 #include <stdint.h> // for uint64_t
11 #include <stdio.h> // for FILE
12 #include "gfxRect.h" // for gfxRect
13 #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
14 #include "mozilla/Attributes.h" // for override
15 #include "mozilla/RefPtr.h" // for RefPtr, RefCounted, etc
16 // #include "mozilla/gfx/MatrixFwd.h" // for Matrix4x4
17 #include "mozilla/gfx/Polygon.h" // for Polygon
18 #include "mozilla/gfx/Rect.h" // for Rect
19 #include "mozilla/ipc/ProtocolUtils.h"
20 #include "mozilla/layers/CompositorTypes.h" // for TextureInfo, etc
21 // #include "mozilla/layers/LayersTypes.h" // for LayerRenderState, etc
22 #include "mozilla/layers/LayersMessages.h"
23 #include "mozilla/layers/TextureHost.h" // for TextureHost
24 #include "nsCOMPtr.h" // for already_AddRefed
25 #include "nscore.h" // for nsACString
26 #include "Units.h" // for CSSToScreenScale
32 class WebRenderImageHost
;
34 struct ImageCompositeNotificationInfo
{
35 base::ProcessId mImageBridgeProcessId
;
36 ImageCompositeNotification mNotification
;
39 struct AsyncCompositableRef
{
40 AsyncCompositableRef() : mProcessId(base::kInvalidProcessId
) {}
41 AsyncCompositableRef(base::ProcessId aProcessId
,
42 const CompositableHandle
& aHandle
)
43 : mProcessId(aProcessId
), mHandle(aHandle
) {}
44 explicit operator bool() const { return !!mHandle
; }
45 base::ProcessId mProcessId
;
46 CompositableHandle mHandle
;
50 * The compositor-side counterpart to CompositableClient. Responsible for
51 * updating textures and data about textures from IPC and how textures are
52 * composited (tiling, double buffering, etc.).
54 * Update (for images/canvases) and UpdateThebes (for Thebes) are called during
55 * the layers transaction to update the Compositbale's textures from the
56 * content side. The actual update (and any syncronous upload) is done by the
57 * TextureHost, but it is coordinated by the CompositableHost.
59 * Composite is called by the owning layer when it is composited.
60 * CompositableHost will use its TextureHost(s) and call Compositor::DrawQuad to
61 * do the actual rendering.
63 class CompositableHost
{
65 virtual ~CompositableHost();
68 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositableHost
)
69 explicit CompositableHost(const TextureInfo
& aTextureInfo
);
71 static already_AddRefed
<CompositableHost
> Create(
72 const TextureInfo
& aTextureInfo
);
74 virtual WebRenderImageHost
* AsWebRenderImageHost() { return nullptr; }
76 virtual void Dump(std::stringstream
& aStream
, const char* aPrefix
= "",
77 bool aDumpHtml
= false) {}
78 static void DumpTextureHost(std::stringstream
& aStream
,
79 TextureHost
* aTexture
);
82 CompositableTextureHostRef mTexture
;
84 gfx::IntRect mPictureRect
;
88 virtual void UseTextureHost(const nsTArray
<TimedTexture
>& aTextures
);
89 virtual void RemoveTextureHost(TextureHost
* aTexture
);
91 uint64_t GetCompositorBridgeID() const { return mCompositorBridgeID
; }
93 const AsyncCompositableRef
& GetAsyncRef() const { return mAsyncRef
; }
94 void SetAsyncRef(const AsyncCompositableRef
& aRef
) { mAsyncRef
= aRef
; }
96 void SetCompositorBridgeID(uint64_t aID
) { mCompositorBridgeID
= aID
; }
98 /// Called when shutting down the layer tree.
99 /// This is a good place to clear all potential gpu resources before the
100 /// widget is is destroyed.
101 virtual void CleanupResources() {}
103 virtual void OnReleased() {}
105 virtual uint32_t GetDroppedFrames() { return 0; }
109 TextureInfo mTextureInfo
;
110 AsyncCompositableRef mAsyncRef
;
111 uint64_t mCompositorBridgeID
;
114 } // namespace layers
115 } // namespace mozilla