mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 14:55:47 +00:00
Bug 1743847 - Throw an exception in WebGPU GetCurrentTexture r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D133143
This commit is contained in:
parent
ed77e7c029
commit
7f7df83147
@ -61,11 +61,14 @@ bool CanvasContext::UpdateWebRenderCanvasData(
|
||||
void CanvasContext::Configure(const dom::GPUCanvasConfiguration& aDesc) {
|
||||
Unconfigure();
|
||||
|
||||
// these formats are guaranteed by the spec
|
||||
switch (aDesc.mFormat) {
|
||||
case dom::GPUTextureFormat::Rgba8unorm:
|
||||
case dom::GPUTextureFormat::Rgba8unorm_srgb:
|
||||
mGfxFormat = gfx::SurfaceFormat::R8G8B8A8;
|
||||
break;
|
||||
case dom::GPUTextureFormat::Bgra8unorm:
|
||||
case dom::GPUTextureFormat::Bgra8unorm_srgb:
|
||||
mGfxFormat = gfx::SurfaceFormat::B8G8R8A8;
|
||||
break;
|
||||
default:
|
||||
@ -102,13 +105,20 @@ void CanvasContext::Unconfigure() {
|
||||
}
|
||||
mBridge = nullptr;
|
||||
mTexture = nullptr;
|
||||
mGfxFormat = gfx::SurfaceFormat::UNKNOWN;
|
||||
}
|
||||
|
||||
dom::GPUTextureFormat CanvasContext::GetPreferredFormat(Adapter&) const {
|
||||
return dom::GPUTextureFormat::Bgra8unorm;
|
||||
}
|
||||
|
||||
RefPtr<Texture> CanvasContext::GetCurrentTexture() { return mTexture; }
|
||||
RefPtr<Texture> CanvasContext::GetCurrentTexture(ErrorResult& aRv) {
|
||||
if (!mTexture) {
|
||||
aRv.ThrowOperationError("Canvas not configured");
|
||||
return nullptr;
|
||||
}
|
||||
return mTexture;
|
||||
}
|
||||
|
||||
bool CanvasContext::UpdateWebRenderLocalCanvasData(
|
||||
layers::WebRenderLocalCanvasData* aCanvasData) {
|
||||
|
@ -98,7 +98,7 @@ class CanvasContext final : public nsICanvasRenderingContextInternal,
|
||||
void Unconfigure();
|
||||
|
||||
dom::GPUTextureFormat GetPreferredFormat(Adapter& aAdapter) const;
|
||||
RefPtr<Texture> GetCurrentTexture();
|
||||
RefPtr<Texture> GetCurrentTexture(ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
uint32_t mWidth = 0, mHeight = 0;
|
||||
|
@ -246,8 +246,8 @@ already_AddRefed<Texture> Device::InitSwapChain(
|
||||
} else {
|
||||
MOZ_CRASH("Unexpected union");
|
||||
}
|
||||
*aCanvasSize = size;
|
||||
}
|
||||
*aCanvasSize = size;
|
||||
|
||||
const layers::RGBDescriptor rgbDesc(size, aFormat);
|
||||
// buffer count doesn't matter much, will be created on demand
|
||||
|
@ -20,7 +20,7 @@ static mozilla::LazyLogModule sLogger("WebGPU");
|
||||
// TODO: refactor this to avoid stack-allocating the buffer all the time.
|
||||
class ErrorBuffer {
|
||||
// if the message doesn't fit, it will be truncated
|
||||
static constexpr unsigned BUFFER_SIZE = 256;
|
||||
static constexpr unsigned BUFFER_SIZE = 512;
|
||||
char mUtf8[BUFFER_SIZE] = {};
|
||||
bool mGuard = false;
|
||||
|
||||
|
@ -1171,5 +1171,6 @@ interface GPUCanvasContext {
|
||||
void unconfigure();
|
||||
|
||||
GPUTextureFormat getPreferredFormat(GPUAdapter adapter);
|
||||
[Throws]
|
||||
GPUTexture getCurrentTexture();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user