Bug 1406230 - Check for APPLE_fence/APPLE_texture_range/APPLE_client_storage extensions, r?mattwoodrow draft
authorMartin Stransky <stransky@redhat.com>
Fri, 27 Jul 2018 11:13:21 +0200
changeset 823405 5c3ea5c0690c2ae2c354d8c1b63902ab43992d17
parent 823003 b48ea3677d66a4dd6347892af18538be60d1e9b6
child 823468 bb105bcf92b90d74788b52351ff5a79d9647c548
child 824211 2a647be20fe598b9e7a1fc4a93d68b7587c5fb89
push id117675
push userstransky@redhat.com
push dateFri, 27 Jul 2018 09:14:02 +0000
reviewersmattwoodrow
bugs1406230
milestone63.0a1
Bug 1406230 - Check for APPLE_fence/APPLE_texture_range/APPLE_client_storage extensions, r?mattwoodrow MozReview-Commit-ID: Ips3QrguVfX
gfx/layers/opengl/TextureHostOGL.cpp
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -337,53 +337,63 @@ DirectMapTextureSource::Update(gfx::Data
   return UpdateInternal(aSurface, aDestRegion, aSrcOffset, false);
 }
 
 bool
 DirectMapTextureSource::Sync(bool aBlocking)
 {
   gl()->MakeCurrent();
   if (!gl()->IsDestroyed()) {
-    if (aBlocking) {
-      gl()->fFinishObjectAPPLE(LOCAL_GL_TEXTURE, mTextureHandle);
+    if (gl()->IsExtensionSupported(GLContext::APPLE_fence)) {
+      if (aBlocking) {
+        gl()->fFinishObjectAPPLE(LOCAL_GL_TEXTURE, mTextureHandle);
+      } else {
+        return gl()->fTestObjectAPPLE(LOCAL_GL_TEXTURE, mTextureHandle);
+      }
     } else {
-      return gl()->fTestObjectAPPLE(LOCAL_GL_TEXTURE, mTextureHandle);
+      gl()->fFinish();
     }
   }
+
   return true;
 }
 
 bool
 DirectMapTextureSource::UpdateInternal(gfx::DataSourceSurface* aSurface,
                                        nsIntRegion* aDestRegion,
                                        gfx::IntPoint* aSrcOffset,
                                        bool aInit)
 {
   gl()->MakeCurrent();
 
   if (aInit) {
     gl()->fGenTextures(1, &mTextureHandle);
     gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTextureHandle);
 
-    gl()->fTexParameteri(LOCAL_GL_TEXTURE_2D,
-                         LOCAL_GL_TEXTURE_STORAGE_HINT_APPLE,
-                         LOCAL_GL_STORAGE_CACHED_APPLE);
+    if (gl()->IsExtensionSupported(GLContext::APPLE_texture_range)) {
+      gl()->fTexParameteri(LOCAL_GL_TEXTURE_2D,
+                           LOCAL_GL_TEXTURE_STORAGE_HINT_APPLE,
+                           LOCAL_GL_STORAGE_CACHED_APPLE);
+    }
 
     gl()->fTexParameteri(LOCAL_GL_TEXTURE_2D,
                          LOCAL_GL_TEXTURE_WRAP_S,
                          LOCAL_GL_CLAMP_TO_EDGE);
     gl()->fTexParameteri(LOCAL_GL_TEXTURE_2D,
                          LOCAL_GL_TEXTURE_WRAP_T,
                          LOCAL_GL_CLAMP_TO_EDGE);
   }
 
   MOZ_ASSERT(mTextureHandle);
 
   // APPLE_client_storage
-  gl()->fPixelStorei(LOCAL_GL_UNPACK_CLIENT_STORAGE_APPLE, LOCAL_GL_TRUE);
+  bool hasStorage = gl()->IsExtensionSupported(GLContext::APPLE_client_storage);
+  if (hasStorage) {
+    gl()->fPixelStorei(LOCAL_GL_UNPACK_CLIENT_STORAGE_APPLE, LOCAL_GL_TRUE);
+  }
 
   nsIntRegion destRegion = aDestRegion ? *aDestRegion
                                        : IntRect(0, 0,
                                                  aSurface->GetSize().width,
                                                  aSurface->GetSize().height);
   gfx::IntPoint srcPoint = aSrcOffset ? *aSrcOffset
                                       : gfx::IntPoint(0, 0);
   mFormat = gl::UploadSurfaceToTexture(gl(),
@@ -392,17 +402,19 @@ DirectMapTextureSource::UpdateInternal(g
                                        mTextureHandle,
                                        aSurface->GetSize(),
                                        nullptr,
                                        aInit,
                                        srcPoint,
                                        LOCAL_GL_TEXTURE0,
                                        LOCAL_GL_TEXTURE_2D);
 
-  gl()->fPixelStorei(LOCAL_GL_UNPACK_CLIENT_STORAGE_APPLE, LOCAL_GL_FALSE);
+  if (hasStorage) {
+    gl()->fPixelStorei(LOCAL_GL_UNPACK_CLIENT_STORAGE_APPLE, LOCAL_GL_FALSE);
+  }
   return true;
 }
 
 ////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////
 // SurfaceTextureHost
 
 #ifdef MOZ_WIDGET_ANDROID