diff options
Diffstat (limited to 'gfx/gl')
-rw-r--r-- | gfx/gl/GLContextProviderGLX.cpp | 1 | ||||
-rw-r--r-- | gfx/gl/GLLibraryEGL.cpp | 15 | ||||
-rw-r--r-- | gfx/gl/GLTextureImage.cpp | 3 | ||||
-rw-r--r-- | gfx/gl/GLUploadHelpers.cpp | 71 | ||||
-rw-r--r-- | gfx/gl/GLUploadHelpers.h | 2 | ||||
-rw-r--r-- | gfx/gl/TextureImageEGL.cpp | 4 |
6 files changed, 38 insertions, 58 deletions
diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index 5560357e1..539520a8c 100644 --- a/gfx/gl/GLContextProviderGLX.cpp +++ b/gfx/gl/GLContextProviderGLX.cpp @@ -80,7 +80,6 @@ GLXLibrary::EnsureInitialized() if (!mOGLLibrary) { const char* libGLfilename = nullptr; - bool forceFeatureReport = false; // see e.g. bug 608526: it is intrinsically interesting to know whether we have dynamically linked to libGL.so.1 // because at least the NVIDIA implementation requires an executable stack, which causes mprotect calls, diff --git a/gfx/gl/GLLibraryEGL.cpp b/gfx/gl/GLLibraryEGL.cpp index 3d8da3085..75f40f13f 100644 --- a/gfx/gl/GLLibraryEGL.cpp +++ b/gfx/gl/GLLibraryEGL.cpp @@ -9,7 +9,6 @@ #include "gfxUtils.h" #include "mozilla/Preferences.h" #include "mozilla/Assertions.h" -#include "mozilla/Telemetry.h" #include "mozilla/Tokenizer.h" #include "mozilla/ScopeExit.h" #include "mozilla/Unused.h" @@ -472,20 +471,6 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId chosenDisplay = GetAndInitDisplayForAccelANGLE(*this, out_failureId); } - // Report the acceleration status to telemetry - if (!chosenDisplay) { - if (accelAngleFailureId.IsEmpty()) { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_ACCL_FAILURE_ID, - NS_LITERAL_CSTRING("FEATURE_FAILURE_ACCL_ANGLE_UNKNOWN")); - } else { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_ACCL_FAILURE_ID, - accelAngleFailureId); - } - } else { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_ACCL_FAILURE_ID, - NS_LITERAL_CSTRING("SUCCESS")); - } - // Fallback to a WARP display if ANGLE fails, or if WARP is forced if (!chosenDisplay && shouldTryWARP) { chosenDisplay = GetAndInitWARPDisplay(*this, EGL_DEFAULT_DISPLAY); diff --git a/gfx/gl/GLTextureImage.cpp b/gfx/gl/GLTextureImage.cpp index 65678432d..c91d558af 100644 --- a/gfx/gl/GLTextureImage.cpp +++ b/gfx/gl/GLTextureImage.cpp @@ -149,9 +149,6 @@ BasicTextureImage::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion &uploadSize, needInit, aFrom); - if (mTextureFormat == SurfaceFormat::UNKNOWN) { - return false; - } if (uploadSize > 0) { UpdateUploadSize(uploadSize); diff --git a/gfx/gl/GLUploadHelpers.cpp b/gfx/gl/GLUploadHelpers.cpp index ca1c890a4..0bbb61434 100644 --- a/gfx/gl/GLUploadHelpers.cpp +++ b/gfx/gl/GLUploadHelpers.cpp @@ -27,23 +27,6 @@ DataOffset(const IntPoint& aPoint, int32_t aStride, SurfaceFormat aFormat) return data; } -static bool -CheckUploadBounds(const IntSize& aDst, const IntSize& aSrc, const IntPoint& aOffset) -{ - if (aOffset.x < 0 || aOffset.y < 0 || - aOffset.x >= aSrc.width || - aOffset.y >= aSrc.height) { - MOZ_ASSERT_UNREACHABLE("Offset outside source bounds"); - return false; - } - if (aDst.width > (aSrc.width - aOffset.x) || - aDst.height > (aSrc.height - aOffset.y)) { - MOZ_ASSERT_UNREACHABLE("Source has insufficient data"); - return false; - } - return true; -} - static GLint GetAddressAlignment(ptrdiff_t aAddress) { if (!(aAddress & 0x7)) { @@ -178,7 +161,22 @@ TexSubImage2DWithoutUnpackSubimage(GLContext* gl, // isn't supported. We make a copy of the texture data we're using, // such that we're using the whole row of data in the copy. This turns // out to be more efficient than uploading row-by-row; see bug 698197. - unsigned char* newPixels = new (fallible) unsigned char[width*height*pixelsize]; + + // Width and height are never more than 16384. At 16Ki*16Ki, 4Bpp is 1GiB, but + // if we allow 8Bpp (16-bit channels, or higher) here, that's 2GiB+, which would + // overflow on 32-bit. + MOZ_ASSERT(width <= 16384); + MOZ_ASSERT(height <= 16384); + MOZ_ASSERT(pixelsize < 8); + + const auto size = CheckedInt<size_t>(width) * height * pixelsize; + if (!size.isValid()) { + // This should never happen, but we use a defensive check. + MOZ_ASSERT_UNREACHABLE("Unacceptable size calculated.!"); + return; + } + + unsigned char* newPixels = new (fallible) unsigned char[size.value()]; if (newPixels) { unsigned char* rowDest = newPixels; @@ -303,7 +301,22 @@ TexImage2DHelper(GLContext* gl, GLsizei paddedWidth = RoundUpPow2((uint32_t)width); GLsizei paddedHeight = RoundUpPow2((uint32_t)height); - GLvoid* paddedPixels = new unsigned char[paddedWidth * paddedHeight * pixelsize]; + // Width and height are never more than 16384. At 16Ki*16Ki, 4Bpp + // is 1GiB, but if we allow 8Bpp (or higher) here, that's 2GiB, + // which would overflow on 32-bit. + MOZ_ASSERT(width <= 16384); + MOZ_ASSERT(height <= 16384); + MOZ_ASSERT(pixelsize < 8); + + const auto size = + CheckedInt<size_t>(paddedWidth) * paddedHeight * pixelsize; + if (!size.isValid()) { + // This should never happen, but we use a defensive check. + MOZ_ASSERT_UNREACHABLE("Unacceptable size calculated.!"); + return; + } + + GLvoid* paddedPixels = new unsigned char[size.value()]; // Pad out texture data to be in a POT sized buffer for uploading to // a POT sized texture @@ -392,7 +405,6 @@ TexImage2DHelper(GLContext* gl, SurfaceFormat UploadImageDataToTexture(GLContext* gl, unsigned char* aData, - const gfx::IntSize& aDataSize, int32_t aStride, SurfaceFormat aFormat, const nsIntRegion& aDstRegion, @@ -483,13 +495,17 @@ UploadImageDataToTexture(GLContext* gl, surfaceFormat = SurfaceFormat::A8; break; default: - NS_ASSERTION(false, "Unhandled image surface format!"); + MOZ_ASSERT_UNREACHABLE("Unhandled image surface format!"); } if (aOutUploadSize) { *aOutUploadSize = 0; } + if (surfaceFormat == gfx::SurfaceFormat::UNKNOWN) { + return gfx::SurfaceFormat::UNKNOWN; + } + if (aNeedInit || !CanUploadSubTextures(gl)) { // If the texture needs initialized, or we are unable to // upload sub textures, then initialize and upload the entire @@ -516,10 +532,6 @@ UploadImageDataToTexture(GLContext* gl, // Upload each rect in the region to the texture for (auto iter = aDstRegion.RectIter(); !iter.Done(); iter.Next()) { const IntRect& rect = iter.Get(); - if (!CheckUploadBounds(rect.Size(), aDataSize, rect.TopLeft())) { - return SurfaceFormat::UNKNOWN; - } - const unsigned char* rectData = aData + DataOffset(rect.TopLeft(), aStride, aFormat); @@ -556,17 +568,10 @@ UploadSurfaceToTexture(GLContext* gl, int32_t stride = aSurface->Stride(); SurfaceFormat format = aSurface->GetFormat(); - gfx::IntSize size = aSurface->GetSize(); - if (!CheckUploadBounds(aSize, size, aSrcPoint)) { - return SurfaceFormat::UNKNOWN; - } - unsigned char* data = aSurface->GetData() + DataOffset(aSrcPoint, stride, format); - size.width -= aSrcPoint.x; - size.height -= aSrcPoint.y; - return UploadImageDataToTexture(gl, data, size, stride, format, + return UploadImageDataToTexture(gl, data, stride, format, aDstRegion, aTexture, aSize, aOutUploadSize, aNeedInit, aTextureUnit, aTextureTarget); diff --git a/gfx/gl/GLUploadHelpers.h b/gfx/gl/GLUploadHelpers.h index f732d2b38..866d44adb 100644 --- a/gfx/gl/GLUploadHelpers.h +++ b/gfx/gl/GLUploadHelpers.h @@ -28,7 +28,6 @@ class GLContext; * \param gl The GL Context to use. * \param aData Start of image data of surface to upload. * Corresponds to the first pixel of the texture. - * \param aDataSize The image data's size. * \param aStride The image data's stride. * \param aFormat The image data's format. * \param aDstRegion Region of the texture to upload. @@ -47,7 +46,6 @@ class GLContext; gfx::SurfaceFormat UploadImageDataToTexture(GLContext* gl, unsigned char* aData, - const gfx::IntSize& aDataSize, int32_t aStride, gfx::SurfaceFormat aFormat, const nsIntRegion& aDstRegion, diff --git a/gfx/gl/TextureImageEGL.cpp b/gfx/gl/TextureImageEGL.cpp index 3bb2987d1..87a547c26 100644 --- a/gfx/gl/TextureImageEGL.cpp +++ b/gfx/gl/TextureImageEGL.cpp @@ -119,10 +119,6 @@ TextureImageEGL::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& &uploadSize, needInit, aFrom); - if (mTextureFormat == SurfaceFormat::UNKNOWN) { - return false; - } - if (uploadSize > 0) { UpdateUploadSize(uploadSize); } |