1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #include "mozilla/GfxMessageUtils.h"
10 #include "mozilla/dom/ipc/IdType.h"
11 #include "mozilla/dom/PWebGLParent.h"
12 #include "mozilla/WeakPtr.h"
16 class HostWebGLContext
;
20 class SharedSurfacesHolder
;
21 class SharedSurfaceTextureClient
;
22 class SurfaceDescriptor
;
27 class WebGLParent
: public PWebGLParent
, public SupportsWeakPtr
{
31 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebGLParent
, override
);
33 mozilla::ipc::IPCResult
RecvInitialize(const webgl::InitContextDesc
&,
34 webgl::InitContextResult
* out
);
36 WebGLParent(layers::SharedSurfacesHolder
* aSharedSurfacesHolder
,
37 const dom::ContentParentId
& aContentId
); // For IPDL
39 using IPCResult
= mozilla::ipc::IPCResult
;
41 template <class ResolveT
>
42 IPCResult
RecvPing(const ResolveT
& Resolve
) {
47 IPCResult
RecvSyncPing() { return IPC_OK(); }
49 IPCResult
RecvDispatchCommands(mozilla::ipc::BigBuffer
&&, uint64_t);
50 IPCResult
RecvTexImage(uint32_t level
, uint32_t respecFormat
,
51 const uvec3
& offset
, const webgl::PackingInfo
&,
52 webgl::TexUnpackBlobDesc
&&);
54 IPCResult
RecvGetBufferSubData(GLenum target
, uint64_t srcByteOffset
,
55 uint64_t byteSize
, mozilla::ipc::Shmem
* ret
);
56 IPCResult
GetFrontBufferSnapshot(webgl::FrontBufferSnapshotIpc
* ret
,
57 IProtocol
* aProtocol
);
58 IPCResult
RecvGetFrontBufferSnapshot(webgl::FrontBufferSnapshotIpc
* ret
);
59 IPCResult
RecvReadPixels(const webgl::ReadPixelsDesc
&,
60 ReadPixelsBuffer
&& buffer
,
61 webgl::ReadPixelsResultIpc
* ret
);
65 using ObjectId
= webgl::ObjectId
;
67 IPCResult
RecvCheckFramebufferStatus(GLenum target
, GLenum
* ret
);
68 IPCResult
RecvClientWaitSync(ObjectId id
, GLbitfield flags
, GLuint64 timeout
,
70 IPCResult
RecvCreateOpaqueFramebuffer(ObjectId id
,
71 const OpaqueFramebufferOptions
&,
73 IPCResult
RecvDrawingBufferSize(uvec2
* ret
);
74 IPCResult
RecvFinish();
75 IPCResult
RecvGetBufferParameter(GLenum target
, GLenum pname
,
77 IPCResult
RecvGetCompileResult(ObjectId id
, webgl::CompileResult
* ret
);
78 IPCResult
RecvGetError(GLenum
* ret
);
79 IPCResult
RecvGetFragDataLocation(ObjectId id
, const std::string
& name
,
81 IPCResult
RecvGetFramebufferAttachmentParameter(ObjectId id
,
85 IPCResult
RecvGetFrontBuffer(ObjectId fb
, bool vr
,
86 Maybe
<layers::SurfaceDescriptor
>* ret
);
87 IPCResult
RecvGetIndexedParameter(GLenum target
, GLuint index
,
89 IPCResult
RecvGetInternalformatParameter(GLenum target
, GLuint format
,
91 Maybe
<std::vector
<int32_t>>* ret
);
92 IPCResult
RecvGetLinkResult(ObjectId id
, webgl::LinkResult
* ret
);
93 IPCResult
RecvGetNumber(GLenum pname
, Maybe
<double>* ret
);
94 IPCResult
RecvGetQueryParameter(ObjectId id
, GLenum pname
,
96 IPCResult
RecvGetRenderbufferParameter(ObjectId id
, GLenum pname
,
98 IPCResult
RecvGetSamplerParameter(ObjectId id
, GLenum pname
,
100 IPCResult
RecvGetShaderPrecisionFormat(
101 GLenum shaderType
, GLenum precisionType
,
102 Maybe
<webgl::ShaderPrecisionFormat
>* ret
);
103 IPCResult
RecvGetString(GLenum pname
, Maybe
<std::string
>* ret
);
104 IPCResult
RecvGetTexParameter(ObjectId id
, GLenum pname
, Maybe
<double>* ret
);
105 IPCResult
RecvGetUniform(ObjectId id
, uint32_t loc
,
106 webgl::GetUniformData
* ret
);
107 IPCResult
RecvGetVertexAttrib(GLuint index
, GLenum pname
, Maybe
<double>* ret
);
108 IPCResult
RecvOnMemoryPressure();
109 IPCResult
RecvValidateProgram(ObjectId id
, bool* ret
);
113 const RefPtr
<layers::SharedSurfacesHolder
> mSharedSurfacesHolder
;
114 const dom::ContentParentId mContentId
;
119 mozilla::ipc::IPCResult
Recv__delete__() override
;
121 void ActorDestroy(ActorDestroyReason aWhy
) override
;
123 mozilla::ipc::IPCResult
RecvWaitForTxn(layers::RemoteTextureOwnerId aOwnerId
,
124 layers::RemoteTextureTxnType aTxnType
,
125 layers::RemoteTextureTxnId aTxnId
);
127 UniquePtr
<HostWebGLContext
> mHost
;
129 // Runnable that repeatedly processes our WebGL command queue
130 RefPtr
<Runnable
> mRunCommandsRunnable
;
134 } // namespace mozilla
136 #endif // WEBGLPARENT_H_