2020-01-09 01:19:14 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "WebGLParent.h"
|
|
|
|
|
2020-05-01 01:24:44 +03:00
|
|
|
#include "WebGLChild.h"
|
2020-01-09 01:19:14 +03:00
|
|
|
#include "mozilla/layers/TextureClientSharedSurface.h"
|
2020-10-20 16:14:51 +03:00
|
|
|
#include "ImageContainer.h"
|
2020-01-09 01:19:14 +03:00
|
|
|
#include "HostWebGLContext.h"
|
2020-07-22 01:56:52 +03:00
|
|
|
#include "WebGLMethodDispatcher.h"
|
2020-01-09 01:19:14 +03:00
|
|
|
|
2020-11-04 20:04:01 +03:00
|
|
|
namespace mozilla::dom {
|
2020-01-09 01:19:14 +03:00
|
|
|
|
2020-05-01 01:23:48 +03:00
|
|
|
mozilla::ipc::IPCResult WebGLParent::RecvInitialize(
|
2021-02-15 11:49:20 +03:00
|
|
|
const webgl::InitContextDesc& desc, webgl::InitContextResult* const out) {
|
|
|
|
mHost = HostWebGLContext::Create({nullptr, this}, desc, out);
|
2020-01-09 01:19:16 +03:00
|
|
|
|
2022-12-15 22:02:12 +03:00
|
|
|
if (!mHost) {
|
2024-01-04 21:38:53 +03:00
|
|
|
MOZ_ASSERT(!out->error->empty());
|
2020-01-09 01:19:14 +03:00
|
|
|
}
|
2020-05-01 01:23:48 +03:00
|
|
|
|
|
|
|
return IPC_OK();
|
2020-01-09 01:19:14 +03:00
|
|
|
}
|
|
|
|
|
2023-12-06 22:31:32 +03:00
|
|
|
WebGLParent::WebGLParent(const dom::ContentParentId& aContentId)
|
|
|
|
: mContentId(aContentId) {}
|
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
WebGLParent::~WebGLParent() = default;
|
2020-01-09 01:19:14 +03:00
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
// -
|
|
|
|
|
|
|
|
using IPCResult = mozilla::ipc::IPCResult;
|
2020-01-09 01:19:14 +03:00
|
|
|
|
2022-11-26 01:20:38 +03:00
|
|
|
IPCResult WebGLParent::RecvDispatchCommands(BigBuffer&& shmem,
|
2020-07-22 01:56:52 +03:00
|
|
|
const uint64_t cmdsByteSize) {
|
2021-12-31 03:56:07 +03:00
|
|
|
AUTO_PROFILER_LABEL("WebGLParent::RecvDispatchCommands", GRAPHICS);
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-09-02 02:29:01 +03:00
|
|
|
const auto& gl = mHost->mContext->GL();
|
|
|
|
const gl::GLContext::TlsScope tlsIsCurrent(gl);
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
MOZ_ASSERT(cmdsByteSize);
|
2022-11-26 01:20:38 +03:00
|
|
|
const auto shmemBytes = Range<uint8_t>{shmem.AsSpan()};
|
2020-07-22 01:56:52 +03:00
|
|
|
const auto byteSize = std::min<uint64_t>(shmemBytes.length(), cmdsByteSize);
|
|
|
|
const auto cmdsBytes =
|
|
|
|
Range<const uint8_t>{shmemBytes.begin(), shmemBytes.begin() + byteSize};
|
|
|
|
auto view = webgl::RangeConsumerView{cmdsBytes};
|
|
|
|
|
2021-04-17 06:45:10 +03:00
|
|
|
if (kIsDebug) {
|
|
|
|
const auto initialOffset =
|
|
|
|
AlignmentOffset(kUniversalAlignment, cmdsBytes.begin().get());
|
|
|
|
MOZ_ALWAYS_TRUE(!initialOffset);
|
|
|
|
}
|
|
|
|
|
2024-02-08 10:55:45 +03:00
|
|
|
std::optional<std::string> fatalError;
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
while (true) {
|
2020-09-16 10:16:48 +03:00
|
|
|
view.AlignTo(kUniversalAlignment);
|
2020-07-22 01:56:52 +03:00
|
|
|
size_t id = 0;
|
2021-09-11 05:11:11 +03:00
|
|
|
if (!view.ReadParam(&id)) break;
|
2020-07-22 01:56:52 +03:00
|
|
|
|
2024-02-08 10:55:45 +03:00
|
|
|
// We split this up so that we don't end up in a long callstack chain of
|
|
|
|
// WebGLMethodDispatcher<i>|i=0->N. First get the lambda for dispatch, then
|
|
|
|
// invoke the lambda with our args.
|
|
|
|
const auto pfn =
|
|
|
|
WebGLMethodDispatcher<0>::DispatchCommandFuncById<HostWebGLContext>(id);
|
|
|
|
if (!pfn) {
|
|
|
|
const nsPrintfCString cstr(
|
|
|
|
"MethodDispatcher<%zu> not found. Please file a bug!", id);
|
|
|
|
fatalError = ToString(cstr);
|
|
|
|
gfxCriticalError() << *fatalError;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto ok = (*pfn)(*mHost, view);
|
2021-04-17 06:45:10 +03:00
|
|
|
if (!ok) {
|
|
|
|
const nsPrintfCString cstr(
|
2024-02-08 10:55:45 +03:00
|
|
|
"DispatchCommand(id: %zu) failed. Please file a bug!", id);
|
|
|
|
fatalError = ToString(cstr);
|
|
|
|
gfxCriticalError() << *fatalError;
|
2021-04-17 06:45:10 +03:00
|
|
|
break;
|
|
|
|
}
|
2020-01-09 01:19:14 +03:00
|
|
|
}
|
|
|
|
|
2024-02-08 10:55:45 +03:00
|
|
|
if (fatalError) {
|
|
|
|
mHost->JsWarning(*fatalError);
|
|
|
|
mHost->OnContextLoss(webgl::ContextLossReason::None);
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2021-12-15 04:54:21 +03:00
|
|
|
IPCResult WebGLParent::RecvTexImage(const uint32_t level,
|
|
|
|
const uint32_t respecFormat,
|
|
|
|
const uvec3& offset,
|
|
|
|
const webgl::PackingInfo& pi,
|
|
|
|
webgl::TexUnpackBlobDesc&& desc) {
|
2021-12-31 03:56:07 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2021-12-15 04:54:21 +03:00
|
|
|
mHost->TexImage(level, respecFormat, offset, pi, desc);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
// -
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult WebGLParent::Recv__delete__() {
|
|
|
|
mHost = nullptr;
|
|
|
|
return IPC_OK();
|
2020-01-09 01:19:14 +03:00
|
|
|
}
|
|
|
|
|
2022-07-12 09:56:19 +03:00
|
|
|
void WebGLParent::ActorDestroy(ActorDestroyReason aWhy) { mHost = nullptr; }
|
2020-07-22 01:56:52 +03:00
|
|
|
|
2024-01-30 18:44:04 +03:00
|
|
|
mozilla::ipc::IPCResult WebGLParent::RecvWaitForTxn(
|
|
|
|
layers::RemoteTextureOwnerId aOwnerId,
|
|
|
|
layers::RemoteTextureTxnType aTxnType, layers::RemoteTextureTxnId aTxnId) {
|
|
|
|
if (mHost) {
|
|
|
|
mHost->WaitForTxn(aOwnerId, aTxnType, aTxnId);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
// -
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetFrontBufferSnapshot(
|
|
|
|
webgl::FrontBufferSnapshotIpc* const ret) {
|
Bug 1736177 - Part 9. Add plumbing to snapshot worker canvas contexts from the main thread. r=jgilbert,ipc-reviewers,nika
Right now, if we wanted to get a snapshot of an OffscreenCanvas context
on a worker thread from the main thread, we would need to block the main
thread on the worker thread, and from the worker thread, issue a sync
IPC call get the front buffer snapshot.
This patch adds an alternative which allows the main thread to go
directly to the canvas owning thread in the compositor process to get
the snapshot, thereby bypassing the worker thread in content process
entirely. All it needs as the unique ID of the CanvasManagerChild
instance, and the protocol ID of the WebGLChild instance.
This will be used for Firefox screenshots, New Tab tiles, and printing.
Differential Revision: https://phabricator.services.mozilla.com/D130785
2021-12-10 05:57:55 +03:00
|
|
|
return GetFrontBufferSnapshot(ret, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::GetFrontBufferSnapshot(
|
|
|
|
webgl::FrontBufferSnapshotIpc* const ret, IProtocol* aProtocol) {
|
2021-12-31 03:56:07 +03:00
|
|
|
AUTO_PROFILER_LABEL("WebGLParent::GetFrontBufferSnapshot", GRAPHICS);
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = {};
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
Bug 1736177 - Part 9. Add plumbing to snapshot worker canvas contexts from the main thread. r=jgilbert,ipc-reviewers,nika
Right now, if we wanted to get a snapshot of an OffscreenCanvas context
on a worker thread from the main thread, we would need to block the main
thread on the worker thread, and from the worker thread, issue a sync
IPC call get the front buffer snapshot.
This patch adds an alternative which allows the main thread to go
directly to the canvas owning thread in the compositor process to get
the snapshot, thereby bypassing the worker thread in content process
entirely. All it needs as the unique ID of the CanvasManagerChild
instance, and the protocol ID of the WebGLChild instance.
This will be used for Firefox screenshots, New Tab tiles, and printing.
Differential Revision: https://phabricator.services.mozilla.com/D130785
2021-12-10 05:57:55 +03:00
|
|
|
return IPC_FAIL(aProtocol, "HostWebGLContext is not initialized.");
|
2021-10-14 22:52:26 +03:00
|
|
|
}
|
|
|
|
|
2022-12-15 22:02:12 +03:00
|
|
|
const bool ok = [&]() {
|
|
|
|
const auto maybeSize = mHost->FrontBufferSnapshotInto({});
|
|
|
|
if (maybeSize) {
|
|
|
|
const auto& surfSize = *maybeSize;
|
|
|
|
const auto byteSize = 4 * surfSize.x * surfSize.y;
|
|
|
|
|
|
|
|
auto shmem = webgl::RaiiShmem::Alloc(aProtocol, byteSize);
|
|
|
|
if (!shmem) {
|
|
|
|
NS_WARNING("Failed to alloc shmem for RecvGetFrontBufferSnapshot.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const auto range = shmem.ByteRange();
|
|
|
|
*ret = {surfSize, Some(shmem.Extract())};
|
|
|
|
|
|
|
|
if (!mHost->FrontBufferSnapshotInto(Some(range))) {
|
|
|
|
gfxCriticalNote << "WebGLParent::RecvGetFrontBufferSnapshot: "
|
|
|
|
"FrontBufferSnapshotInto(some) failed after "
|
|
|
|
"FrontBufferSnapshotInto(none)";
|
|
|
|
return false;
|
|
|
|
}
|
2021-05-06 03:22:42 +03:00
|
|
|
}
|
2022-12-15 22:02:12 +03:00
|
|
|
return true;
|
|
|
|
}();
|
|
|
|
if (!ok) {
|
|
|
|
// Zero means failure, as we still need to send any shmem we alloc.
|
|
|
|
ret->surfSize = {0, 0};
|
2020-07-22 01:57:01 +03:00
|
|
|
}
|
2020-07-22 01:56:52 +03:00
|
|
|
return IPC_OK();
|
2020-01-09 01:19:14 +03:00
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
IPCResult WebGLParent::RecvGetBufferSubData(const GLenum target,
|
|
|
|
const uint64_t srcByteOffset,
|
|
|
|
const uint64_t byteSize,
|
|
|
|
Shmem* const ret) {
|
2021-12-31 03:56:07 +03:00
|
|
|
AUTO_PROFILER_LABEL("WebGLParent::RecvGetBufferSubData", GRAPHICS);
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:57:01 +03:00
|
|
|
const auto allocSize = 1 + byteSize;
|
2022-07-05 23:08:31 +03:00
|
|
|
auto shmem = webgl::RaiiShmem::Alloc(this, allocSize);
|
2020-07-22 01:57:01 +03:00
|
|
|
if (!shmem) {
|
2020-09-02 02:29:01 +03:00
|
|
|
NS_WARNING("Failed to alloc shmem for RecvGetBufferSubData.");
|
2022-12-15 22:02:12 +03:00
|
|
|
return IPC_OK();
|
2020-01-09 01:19:14 +03:00
|
|
|
}
|
|
|
|
|
2020-07-22 01:57:01 +03:00
|
|
|
const auto shmemRange = shmem.ByteRange();
|
|
|
|
const auto dataRange =
|
|
|
|
Range<uint8_t>{shmemRange.begin() + 1, shmemRange.end()};
|
2020-07-22 01:56:52 +03:00
|
|
|
|
2020-07-22 01:57:01 +03:00
|
|
|
// We need to always send the shmem:
|
|
|
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1463831#c2
|
|
|
|
const auto ok = mHost->GetBufferSubData(target, srcByteOffset, dataRange);
|
|
|
|
*(shmemRange.begin().get()) = ok;
|
|
|
|
*ret = shmem.Extract();
|
2020-07-22 01:56:52 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvReadPixels(const webgl::ReadPixelsDesc& desc,
|
2022-07-12 12:25:35 +03:00
|
|
|
ReadPixelsBuffer&& buffer,
|
2020-07-22 01:56:52 +03:00
|
|
|
webgl::ReadPixelsResultIpc* const ret) {
|
2021-12-31 03:56:07 +03:00
|
|
|
AUTO_PROFILER_LABEL("WebGLParent::RecvReadPixels", GRAPHICS);
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = {};
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2022-07-12 12:25:35 +03:00
|
|
|
if (buffer.type() == ReadPixelsBuffer::TShmem) {
|
|
|
|
const auto& shmem = buffer.get_Shmem();
|
|
|
|
const auto range = shmem.Range<uint8_t>();
|
|
|
|
const auto res = mHost->ReadPixelsInto(desc, range);
|
|
|
|
*ret = {res, {}};
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint64_t byteSize = buffer.get_uint64_t();
|
2020-07-22 01:57:01 +03:00
|
|
|
const auto allocSize = std::max<uint64_t>(1, byteSize);
|
2022-07-05 23:08:31 +03:00
|
|
|
auto shmem = webgl::RaiiShmem::Alloc(this, allocSize);
|
2020-07-22 01:57:01 +03:00
|
|
|
if (!shmem) {
|
2020-09-02 02:29:01 +03:00
|
|
|
NS_WARNING("Failed to alloc shmem for RecvReadPixels.");
|
2022-12-15 22:02:12 +03:00
|
|
|
return IPC_OK();
|
2020-07-22 01:56:52 +03:00
|
|
|
}
|
|
|
|
|
2020-07-22 01:57:01 +03:00
|
|
|
const auto range = shmem.ByteRange();
|
2020-01-09 01:19:14 +03:00
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
const auto res = mHost->ReadPixelsInto(desc, range);
|
2022-07-12 12:25:35 +03:00
|
|
|
*ret = {res, Some(shmem.Extract())};
|
2020-07-22 01:56:52 +03:00
|
|
|
return IPC_OK();
|
2020-01-09 01:19:14 +03:00
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
// -
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvCheckFramebufferStatus(GLenum target,
|
|
|
|
GLenum* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->CheckFramebufferStatus(target);
|
2020-01-09 01:19:14 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
IPCResult WebGLParent::RecvClientWaitSync(ObjectId id, GLbitfield flags,
|
|
|
|
GLuint64 timeout, GLenum* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->ClientWaitSync(id, flags, timeout);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2020-01-09 01:19:14 +03:00
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
IPCResult WebGLParent::RecvCreateOpaqueFramebuffer(
|
|
|
|
const ObjectId id, const OpaqueFramebufferOptions& options,
|
|
|
|
bool* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->CreateOpaqueFramebuffer(id, options);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvDrawingBufferSize(uvec2* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->DrawingBufferSize();
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvFinish() {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
mHost->Finish();
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetBufferParameter(GLenum target, GLenum pname,
|
|
|
|
Maybe<double>* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetBufferParameter(target, pname);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetCompileResult(ObjectId id,
|
|
|
|
webgl::CompileResult* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetCompileResult(id);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetError(GLenum* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetError();
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetFragDataLocation(ObjectId id,
|
|
|
|
const std::string& name,
|
|
|
|
GLint* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetFragDataLocation(id, name);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetFramebufferAttachmentParameter(
|
|
|
|
ObjectId id, GLenum attachment, GLenum pname, Maybe<double>* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetFramebufferAttachmentParameter(id, attachment, pname);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetFrontBuffer(
|
|
|
|
ObjectId fb, const bool vr, Maybe<layers::SurfaceDescriptor>* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetFrontBuffer(fb, vr);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetIndexedParameter(GLenum target, GLuint index,
|
|
|
|
Maybe<double>* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetIndexedParameter(target, index);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetInternalformatParameter(
|
|
|
|
const GLenum target, const GLuint format, const GLuint pname,
|
|
|
|
Maybe<std::vector<int32_t>>* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetInternalformatParameter(target, format, pname);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetLinkResult(ObjectId id,
|
|
|
|
webgl::LinkResult* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetLinkResult(id);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetNumber(GLenum pname, Maybe<double>* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetNumber(pname);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetQueryParameter(ObjectId id, GLenum pname,
|
|
|
|
Maybe<double>* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetQueryParameter(id, pname);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetRenderbufferParameter(ObjectId id, GLenum pname,
|
|
|
|
Maybe<double>* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetRenderbufferParameter(id, pname);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetSamplerParameter(ObjectId id, GLenum pname,
|
|
|
|
Maybe<double>* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetSamplerParameter(id, pname);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetShaderPrecisionFormat(
|
|
|
|
GLenum shaderType, GLenum precisionType,
|
|
|
|
Maybe<webgl::ShaderPrecisionFormat>* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetShaderPrecisionFormat(shaderType, precisionType);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetString(GLenum pname,
|
|
|
|
Maybe<std::string>* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetString(pname);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetTexParameter(ObjectId id, GLenum pname,
|
|
|
|
Maybe<double>* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetTexParameter(id, pname);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetUniform(ObjectId id, uint32_t loc,
|
|
|
|
webgl::GetUniformData* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetUniform(id, loc);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvGetVertexAttrib(GLuint index, GLenum pname,
|
|
|
|
Maybe<double>* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->GetVertexAttrib(index, pname);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
IPCResult WebGLParent::RecvOnMemoryPressure() {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
mHost->OnMemoryPressure();
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2020-01-09 01:19:14 +03:00
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
IPCResult WebGLParent::RecvValidateProgram(ObjectId id, bool* const ret) {
|
2021-10-14 22:52:26 +03:00
|
|
|
if (!mHost) {
|
|
|
|
return IPC_FAIL(this, "HostWebGLContext is not initialized.");
|
|
|
|
}
|
|
|
|
|
2020-07-22 01:56:52 +03:00
|
|
|
*ret = mHost->ValidateProgram(id);
|
2020-01-09 01:19:14 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2020-11-04 20:04:01 +03:00
|
|
|
} // namespace mozilla::dom
|