diff options
Diffstat (limited to 'gfx/gl')
-rw-r--r-- | gfx/gl/GLContext.cpp | 4 | ||||
-rw-r--r-- | gfx/gl/GLContextProviderEGL.cpp | 3 | ||||
-rw-r--r-- | gfx/gl/GLContextProviderGLX.cpp | 4 | ||||
-rw-r--r-- | gfx/gl/GLContextProviderWGL.cpp | 5 | ||||
-rw-r--r-- | gfx/gl/GLLibraryEGL.cpp | 12 | ||||
-rw-r--r-- | gfx/gl/GLLibraryEGL.h | 20 | ||||
-rw-r--r-- | gfx/gl/GLTextureImage.cpp | 3 | ||||
-rw-r--r-- | gfx/gl/GLUploadHelpers.cpp | 31 | ||||
-rw-r--r-- | gfx/gl/GLUploadHelpers.h | 2 | ||||
-rw-r--r-- | gfx/gl/TextureImageEGL.cpp | 4 |
10 files changed, 40 insertions, 48 deletions
diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp index 23090ef98..33315413f 100644 --- a/gfx/gl/GLContext.cpp +++ b/gfx/gl/GLContext.cpp @@ -19,7 +19,6 @@ #include "GLReadTexImageHelper.h" #include "GLScreenBuffer.h" -#include "gfxCrashReporterUtils.h" #include "gfxEnv.h" #include "gfxUtils.h" #include "GLContextProvider.h" @@ -523,8 +522,6 @@ GLContext::InitWithPrefix(const char* prefix, bool trygl) MOZ_RELEASE_ASSERT(!mSymbols.fBindFramebuffer, "GFX: InitWithPrefix should only be called once."); - ScopedGfxFeatureReporter reporter("GL Context"); - if (!InitWithPrefixImpl(prefix, trygl)) { // If initialization fails, zero the symbols to avoid hard-to-understand bugs. mSymbols.Zero(); @@ -532,7 +529,6 @@ GLContext::InitWithPrefix(const char* prefix, bool trygl) return false; } - reporter.SetSuccessful(); return true; } diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index ca972e0f3..098662200 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -23,7 +23,7 @@ #ifdef ANDROID #include <android/log.h> - #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args) + #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Android" , ## args) #endif #define GLES2_LIB "libGLESv2.so" @@ -79,7 +79,6 @@ #endif #include "gfxASurface.h" -#include "gfxCrashReporterUtils.h" #include "gfxFailure.h" #include "gfxPlatform.h" #include "gfxUtils.h" diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index 9a1157f33..d804f95af 100644 --- a/gfx/gl/GLContextProviderGLX.cpp +++ b/gfx/gl/GLContextProviderGLX.cpp @@ -35,8 +35,6 @@ #include "GLScreenBuffer.h" #include "gfxPrefs.h" -#include "gfxCrashReporterUtils.h" - #ifdef MOZ_WIDGET_GTK #include "gfxPlatformGtk.h" #endif @@ -93,13 +91,11 @@ GLXLibrary::EnsureInitialized() libGLfilename = "libGL.so.1"; #endif - ScopedGfxFeatureReporter reporter(libGLfilename, forceFeatureReport); mOGLLibrary = PR_LoadLibrary(libGLfilename); if (!mOGLLibrary) { NS_WARNING("Couldn't load OpenGL shared library."); return false; } - reporter.SetSuccessful(); } if (gfxEnv::GlxDebug()) { diff --git a/gfx/gl/GLContextProviderWGL.cpp b/gfx/gl/GLContextProviderWGL.cpp index a1373f78f..c9c3f0a54 100644 --- a/gfx/gl/GLContextProviderWGL.cpp +++ b/gfx/gl/GLContextProviderWGL.cpp @@ -11,8 +11,6 @@ #include "gfxPlatform.h" #include "gfxWindowsSurface.h" -#include "gfxCrashReporterUtils.h" - #include "prenv.h" #include "mozilla/Preferences.h" @@ -99,8 +97,6 @@ WGLLibrary::EnsureInitialized() if (mInitialized) return true; - mozilla::ScopedGfxFeatureReporter reporter("WGL"); - std::string libGLFilename = "Opengl32.dll"; // SU_SPIES_DIRECTORY is for AMD CodeXL/gDEBugger if (PR_GetEnv("SU_SPIES_DIRECTORY")) { @@ -268,7 +264,6 @@ WGLLibrary::EnsureInitialized() mInitialized = true; - reporter.SetSuccessful(); return true; } diff --git a/gfx/gl/GLLibraryEGL.cpp b/gfx/gl/GLLibraryEGL.cpp index 130bce119..3d8da3085 100644 --- a/gfx/gl/GLLibraryEGL.cpp +++ b/gfx/gl/GLLibraryEGL.cpp @@ -6,7 +6,6 @@ #include "angle/Platform.h" #include "gfxConfig.h" -#include "gfxCrashReporterUtils.h" #include "gfxUtils.h" #include "mozilla/Preferences.h" #include "mozilla/Assertions.h" @@ -33,9 +32,6 @@ namespace gl { StaticMutex GLLibraryEGL::sMutex; GLLibraryEGL sEGLLibrary; -#ifdef MOZ_B2G -MOZ_THREAD_LOCAL(EGLContext) GLLibraryEGL::sCurrentContext; -#endif // should match the order of EGLExtensions, and be null-terminated. static const char* sEGLExtensionNames[] = { @@ -303,13 +299,6 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId return true; } - mozilla::ScopedGfxFeatureReporter reporter("EGL"); - -#ifdef MOZ_B2G - if (!sCurrentContext.init()) - MOZ_CRASH("GFX: Tls init failed"); -#endif - #ifdef XP_WIN if (!mEGLLibrary) { // On Windows, the GLESv2, EGL and DXSDK libraries are shipped with libxul and @@ -632,7 +621,6 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId } mInitialized = true; - reporter.SetSuccessful(); return true; } diff --git a/gfx/gl/GLLibraryEGL.h b/gfx/gl/GLLibraryEGL.h index fa6ea748b..88fce067e 100644 --- a/gfx/gl/GLLibraryEGL.h +++ b/gfx/gl/GLLibraryEGL.h @@ -656,32 +656,12 @@ public: static void AfterGLCall(const char* glFunction); #endif -#ifdef MOZ_B2G - EGLContext CachedCurrentContext() { - return sCurrentContext.get(); - } - void UnsetCachedCurrentContext() { - sCurrentContext.set(nullptr); - } - void SetCachedCurrentContext(EGLContext aCtx) { - sCurrentContext.set(aCtx); - } - bool CachedCurrentContextMatches() { - return sCurrentContext.get() == fGetCurrentContext(); - } - -private: - static MOZ_THREAD_LOCAL(EGLContext) sCurrentContext; -public: - -#else EGLContext CachedCurrentContext() { return nullptr; } void UnsetCachedCurrentContext() {} void SetCachedCurrentContext(EGLContext aCtx) { } bool CachedCurrentContextMatches() { return true; } -#endif private: bool mInitialized; diff --git a/gfx/gl/GLTextureImage.cpp b/gfx/gl/GLTextureImage.cpp index c91d558af..65678432d 100644 --- a/gfx/gl/GLTextureImage.cpp +++ b/gfx/gl/GLTextureImage.cpp @@ -149,6 +149,9 @@ 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 75165eedf..ca1c890a4 100644 --- a/gfx/gl/GLUploadHelpers.cpp +++ b/gfx/gl/GLUploadHelpers.cpp @@ -27,6 +27,23 @@ 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)) { @@ -375,6 +392,7 @@ TexImage2DHelper(GLContext* gl, SurfaceFormat UploadImageDataToTexture(GLContext* gl, unsigned char* aData, + const gfx::IntSize& aDataSize, int32_t aStride, SurfaceFormat aFormat, const nsIntRegion& aDstRegion, @@ -498,6 +516,10 @@ 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); @@ -534,10 +556,17 @@ 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, stride, format, + return UploadImageDataToTexture(gl, data, size, stride, format, aDstRegion, aTexture, aSize, aOutUploadSize, aNeedInit, aTextureUnit, aTextureTarget); diff --git a/gfx/gl/GLUploadHelpers.h b/gfx/gl/GLUploadHelpers.h index 866d44adb..f732d2b38 100644 --- a/gfx/gl/GLUploadHelpers.h +++ b/gfx/gl/GLUploadHelpers.h @@ -28,6 +28,7 @@ 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. @@ -46,6 +47,7 @@ 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 87a547c26..3bb2987d1 100644 --- a/gfx/gl/TextureImageEGL.cpp +++ b/gfx/gl/TextureImageEGL.cpp @@ -119,6 +119,10 @@ TextureImageEGL::DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& &uploadSize, needInit, aFrom); + if (mTextureFormat == SurfaceFormat::UNKNOWN) { + return false; + } + if (uploadSize > 0) { UpdateUploadSize(uploadSize); } |