r?jrmuizel - Forbid reads from backbuffer with readBuffer(NONE).
draft
r?jrmuizel - Forbid reads from backbuffer with readBuffer(NONE).
From f833677175112cbfa2957a8a0ab3c8432c767c63 Mon Sep 17 00:00:00 2001
---
dom/canvas/WebGLContext.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
MozReview-Commit-ID: 8DX0lQea0Oi
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -1868,16 +1868,24 @@ WebGLContext::DidRefresh()
bool
WebGLContext::ValidateCurFBForRead(const char* funcName,
const webgl::FormatUsageInfo** const out_format,
uint32_t* const out_width, uint32_t* const out_height,
GLenum* const out_mode)
{
if (!mBoundReadFramebuffer) {
+ const GLenum readBufferMode = gl->Screen()->GetReadBufferMode();
+ if (readBufferMode == LOCAL_GL_NONE) {
+ ErrorInvalidOperation("%s: Can't read from backbuffer when readBuffer mode is"
+ " NONE.",
+ funcName);
+ return false;
+ }
+
ClearBackbufferIfNeeded();
// FIXME - here we're assuming that the default framebuffer is backed by
// UNSIGNED_BYTE that might not always be true, say if we had a 16bpp default
// framebuffer.
auto effFormat = mOptions.alpha ? webgl::EffectiveFormat::RGBA8
: webgl::EffectiveFormat::RGB8;