Bug 1813719: Remove `size` attribute from `GPUCanvasConfiguration`. r=jgilbert,emilio

In [gpuweb#2826](https://github.com/gpuweb/gpuweb/pull/2826), the
`size` attribute was removed from `GPUCanvasConfiguration`. Since the
fuzzers have discovered that the `size` attribute is a fun toy to play
with, it's time to update Firefox to match the spec.

Differential Revision: https://phabricator.services.mozilla.com/D168575
This commit is contained in:
Jim Blandy 2023-02-01 18:32:31 +00:00
Родитель d170c7c9ac
Коммит b204c76991
5 изменённых файлов: 7 добавлений и 28 удалений

Просмотреть файл

@ -67,7 +67,7 @@ void CanvasContext::Configure(const dom::GPUCanvasConfiguration& aDesc) {
gfx::IntSize actualSize(mWidth, mHeight);
mRemoteTextureOwnerId = Some(layers::RemoteTextureOwnerId::GetNext());
mTexture = aDesc.mDevice->InitSwapChain(aDesc, *mRemoteTextureOwnerId,
mGfxFormat, &actualSize);
mGfxFormat, actualSize);
if (!mTexture) {
Unconfigure();
return;
@ -75,7 +75,6 @@ void CanvasContext::Configure(const dom::GPUCanvasConfiguration& aDesc) {
mTexture->mTargetContext = this;
mBridge = aDesc.mDevice->GetBridge();
mGfxSize = actualSize;
ForceNewFrame();
}
@ -151,7 +150,7 @@ bool CanvasContext::InitializeCanvasRenderer(
layers::CanvasRendererData data;
data.mContext = this;
data.mSize = mGfxSize;
data.mSize = gfx::IntSize{mWidth, mHeight};
data.mIsOpaque = false;
data.mRemoteTextureOwnerIdOfPushCallback = mRemoteTextureOwnerId;

Просмотреть файл

@ -97,7 +97,6 @@ class CanvasContext final : public nsICanvasRenderingContextInternal,
RefPtr<WebGPUChild> mBridge;
RefPtr<Texture> mTexture;
gfx::SurfaceFormat mGfxFormat = gfx::SurfaceFormat::R8G8B8A8;
gfx::IntSize mGfxSize;
Maybe<layers::RemoteTextureId> mLastRemoteTextureId;
Maybe<layers::RemoteTextureOwnerId> mRemoteTextureOwnerId;

Просмотреть файл

@ -287,30 +287,12 @@ already_AddRefed<dom::Promise> Device::CreateRenderPipelineAsync(
already_AddRefed<Texture> Device::InitSwapChain(
const dom::GPUCanvasConfiguration& aDesc,
const layers::RemoteTextureOwnerId aOwnerId, gfx::SurfaceFormat aFormat,
gfx::IntSize* aCanvasSize) {
gfx::IntSize aCanvasSize) {
if (!mBridge->CanSend()) {
return nullptr;
}
gfx::IntSize size = *aCanvasSize;
if (aDesc.mSize.WasPassed()) {
const auto& descSize = aDesc.mSize.Value();
if (descSize.IsRangeEnforcedUnsignedLongSequence()) {
const auto& seq = descSize.GetAsRangeEnforcedUnsignedLongSequence();
// TODO: add a check for `seq.Length()`
size.width = AssertedCast<int>(seq[0]);
size.height = AssertedCast<int>(seq[1]);
} else if (descSize.IsGPUExtent3DDict()) {
const auto& dict = descSize.GetAsGPUExtent3DDict();
size.width = AssertedCast<int>(dict.mWidth);
size.height = AssertedCast<int>(dict.mHeight);
} else {
MOZ_CRASH("Unexpected union");
}
*aCanvasSize = size;
}
const layers::RGBDescriptor rgbDesc(size, aFormat);
const layers::RGBDescriptor rgbDesc(aCanvasSize, aFormat);
// buffer count doesn't matter much, will be created on demand
const size_t maxBufferCount = 10;
mBridge->DeviceCreateSwapChain(mId, rgbDesc, maxBufferCount, aOwnerId);
@ -318,8 +300,8 @@ already_AddRefed<Texture> Device::InitSwapChain(
dom::GPUTextureDescriptor desc;
desc.mDimension = dom::GPUTextureDimension::_2d;
auto& sizeDict = desc.mSize.SetAsGPUExtent3DDict();
sizeDict.mWidth = size.width;
sizeDict.mHeight = size.height;
sizeDict.mWidth = aCanvasSize.width;
sizeDict.mHeight = aCanvasSize.height;
sizeDict.mDepthOrArrayLayers = 1;
desc.mFormat = aDesc.mFormat;
desc.mMipLevelCount = 1;

Просмотреть файл

@ -96,7 +96,7 @@ class Device final : public DOMEventTargetHelper, public SupportsWeakPtr {
already_AddRefed<Texture> InitSwapChain(
const dom::GPUCanvasConfiguration& aDesc,
const layers::RemoteTextureOwnerId aOwnerId, gfx::SurfaceFormat aFormat,
gfx::IntSize* aDefaultSize);
gfx::IntSize aDefaultSize);
bool CheckNewWarning(const nsACString& aMessage);
void CleanupUnregisteredInParent();

Просмотреть файл

@ -1092,7 +1092,6 @@ dictionary GPUCanvasConfiguration {
GPUTextureUsageFlags usage = 0x10; //GPUTextureUsage.OUTPUT_ATTACHMENT
//GPUPredefinedColorSpace colorSpace = "srgb"; //TODO
GPUCanvasCompositingAlphaMode compositingAlphaMode = "opaque";
GPUExtent3D size;
};
enum GPUDeviceLostReason {