Merge mozilla-central to autoland on a CLOSED TREE
[gecko.git] / dom / canvas / WebGLParent.h
blobeb87effc84e384beaa1d51c90eeb6000ca7f31ef
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/. */
6 #ifndef WEBGLPARENT_H_
7 #define WEBGLPARENT_H_
9 #include "mozilla/GfxMessageUtils.h"
10 #include "mozilla/dom/PWebGLParent.h"
11 #include "mozilla/WeakPtr.h"
13 namespace mozilla {
15 class HostWebGLContext;
16 class WebGLChild;
18 namespace layers {
19 class SharedSurfaceTextureClient;
20 class SurfaceDescriptor;
21 } // namespace layers
23 namespace dom {
25 class WebGLParent : public PWebGLParent, public SupportsWeakPtr {
26 friend PWebGLParent;
28 public:
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) {
40 Resolve(void_t{});
41 return IPC_OK();
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);
60 // -
62 using ObjectId = webgl::ObjectId;
64 IPCResult RecvCheckFramebufferStatus(GLenum target, GLenum* ret);
65 IPCResult RecvClientWaitSync(ObjectId id, GLbitfield flags, GLuint64 timeout,
66 GLenum* ret);
67 IPCResult RecvCreateOpaqueFramebuffer(ObjectId id,
68 const OpaqueFramebufferOptions&,
69 bool* ret);
70 IPCResult RecvDrawingBufferSize(uvec2* ret);
71 IPCResult RecvFinish();
72 IPCResult RecvGetBufferParameter(GLenum target, GLenum pname,
73 Maybe<double>* ret);
74 IPCResult RecvGetCompileResult(ObjectId id, webgl::CompileResult* ret);
75 IPCResult RecvGetError(GLenum* ret);
76 IPCResult RecvGetFragDataLocation(ObjectId id, const std::string& name,
77 GLint* ret);
78 IPCResult RecvGetFramebufferAttachmentParameter(ObjectId id,
79 GLenum attachment,
80 GLenum pname,
81 Maybe<double>* ret);
82 IPCResult RecvGetFrontBuffer(ObjectId fb, bool vr,
83 Maybe<layers::SurfaceDescriptor>* ret);
84 IPCResult RecvGetIndexedParameter(GLenum target, GLuint index,
85 Maybe<double>* ret);
86 IPCResult RecvGetInternalformatParameter(GLenum target, GLuint format,
87 GLuint pname,
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,
92 Maybe<double>* ret);
93 IPCResult RecvGetRenderbufferParameter(ObjectId id, GLenum pname,
94 Maybe<double>* ret);
95 IPCResult RecvGetSamplerParameter(ObjectId id, GLenum pname,
96 Maybe<double>* ret);
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);
109 // -
111 private:
112 ~WebGLParent();
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;
124 } // namespace dom
125 } // namespace mozilla
127 #endif // WEBGLPARENT_H_