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/PWebGLParent.h"
11 #include "mozilla/WeakPtr.h"
15 class HostWebGLContext
;
19 class SharedSurfaceTextureClient
;
20 class SurfaceDescriptor
;
25 class WebGLParent
: public PWebGLParent
, public SupportsWeakPtr
{
29 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebGLParent
, override
);
31 mozilla::ipc::IPCResult
RecvInitialize(const webgl::InitContextDesc
&,
32 webgl::InitContextResult
* out
);
34 WebGLParent(); // For IPDL
36 using IPCResult
= mozilla::ipc::IPCResult
;
38 template <class ResolveT
>
39 IPCResult
RecvPing(const ResolveT
& Resolve
) {
44 IPCResult
RecvSyncPing() { return IPC_OK(); }
46 IPCResult
RecvDispatchCommands(mozilla::ipc::BigBuffer
&&, uint64_t);
47 IPCResult
RecvTexImage(uint32_t level
, uint32_t respecFormat
,
48 const uvec3
& offset
, const webgl::PackingInfo
&,
49 webgl::TexUnpackBlobDesc
&&);
51 IPCResult
RecvGetBufferSubData(GLenum target
, uint64_t srcByteOffset
,
52 uint64_t byteSize
, mozilla::ipc::Shmem
* ret
);
53 IPCResult
GetFrontBufferSnapshot(webgl::FrontBufferSnapshotIpc
* ret
,
54 IProtocol
* aProtocol
);
55 IPCResult
RecvGetFrontBufferSnapshot(webgl::FrontBufferSnapshotIpc
* ret
);
56 IPCResult
RecvReadPixels(const webgl::ReadPixelsDesc
&,
57 ReadPixelsBuffer
&& buffer
,
58 webgl::ReadPixelsResultIpc
* ret
);
62 using ObjectId
= webgl::ObjectId
;
64 IPCResult
RecvCheckFramebufferStatus(GLenum target
, GLenum
* ret
);
65 IPCResult
RecvClientWaitSync(ObjectId id
, GLbitfield flags
, GLuint64 timeout
,
67 IPCResult
RecvCreateOpaqueFramebuffer(ObjectId id
,
68 const OpaqueFramebufferOptions
&,
70 IPCResult
RecvDrawingBufferSize(uvec2
* ret
);
71 IPCResult
RecvFinish();
72 IPCResult
RecvGetBufferParameter(GLenum target
, GLenum pname
,
74 IPCResult
RecvGetCompileResult(ObjectId id
, webgl::CompileResult
* ret
);
75 IPCResult
RecvGetError(GLenum
* ret
);
76 IPCResult
RecvGetFragDataLocation(ObjectId id
, const std::string
& name
,
78 IPCResult
RecvGetFramebufferAttachmentParameter(ObjectId id
,
82 IPCResult
RecvGetFrontBuffer(ObjectId fb
, bool vr
,
83 Maybe
<layers::SurfaceDescriptor
>* ret
);
84 IPCResult
RecvGetIndexedParameter(GLenum target
, GLuint index
,
86 IPCResult
RecvGetInternalformatParameter(GLenum target
, GLuint format
,
88 Maybe
<std::vector
<int32_t>>* ret
);
89 IPCResult
RecvGetLinkResult(ObjectId id
, webgl::LinkResult
* ret
);
90 IPCResult
RecvGetNumber(GLenum pname
, Maybe
<double>* ret
);
91 IPCResult
RecvGetQueryParameter(ObjectId id
, GLenum pname
,
93 IPCResult
RecvGetRenderbufferParameter(ObjectId id
, GLenum pname
,
95 IPCResult
RecvGetSamplerParameter(ObjectId id
, GLenum pname
,
97 IPCResult
RecvGetShaderPrecisionFormat(
98 GLenum shaderType
, GLenum precisionType
,
99 Maybe
<webgl::ShaderPrecisionFormat
>* ret
);
100 IPCResult
RecvGetString(GLenum pname
, Maybe
<std::string
>* ret
);
101 IPCResult
RecvGetTexParameter(ObjectId id
, GLenum pname
, Maybe
<double>* ret
);
102 IPCResult
RecvGetUniform(ObjectId id
, uint32_t loc
,
103 webgl::GetUniformData
* ret
);
104 IPCResult
RecvGetVertexAttrib(GLuint index
, GLenum pname
, Maybe
<double>* ret
);
105 IPCResult
RecvIsEnabled(GLenum cap
, bool* ret
);
106 IPCResult
RecvOnMemoryPressure();
107 IPCResult
RecvValidateProgram(ObjectId id
, bool* ret
);
114 mozilla::ipc::IPCResult
Recv__delete__() override
;
116 void ActorDestroy(ActorDestroyReason aWhy
) override
;
118 UniquePtr
<HostWebGLContext
> mHost
;
120 // Runnable that repeatedly processes our WebGL command queue
121 RefPtr
<Runnable
> mRunCommandsRunnable
;
125 } // namespace mozilla
127 #endif // WEBGLPARENT_H_