Bug 1464039 - Only reject qcms transform with invalid grid size if the transform function uses the grid size. r=Bas a=jcristau
authorNicolas Silva <nsilva@mozilla.com>
Tue, 19 Jun 2018 15:32:29 +0200
changeset 357244 528d4d997bb306aee3a5e9c65ddfad0c3787e8cf
parent 357243 67b2d8924841a4c44e2907628d35ee8a022ecd2d
child 357245 61e7b79b8327e0672ccd80c66dda6d51b37e4ccb
push id7746
push userjcristau@mozilla.com
push dateTue, 19 Jun 2018 17:27:23 +0000
treeherdermozilla-esr52@528d4d997bb3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, jcristau
bugs1464039
milestone52.9.0
Bug 1464039 - Only reject qcms transform with invalid grid size if the transform function uses the grid size. r=Bas a=jcristau
gfx/qcms/chain.c
gfx/thebes/gfxPlatform.cpp
--- a/gfx/qcms/chain.c
+++ b/gfx/qcms/chain.c
@@ -967,17 +967,19 @@ static float* qcms_modular_transform_dat
 		    transform_fn != qcms_transform_module_clut_only &&
 		    transform_fn != qcms_transform_module_matrix &&
 		    transform_fn != qcms_transform_module_matrix_translate &&
 		    transform_fn != qcms_transform_module_LAB_to_XYZ &&
 		    transform_fn != qcms_transform_module_XYZ_to_LAB) {
 			assert(0 && "Unsupported transform module");
 			return NULL;
 		}
-		if (transform->grid_size <= 0) {
+		if (transform->grid_size <= 0 &&
+			(transform_fn == qcms_transform_module_clut ||
+			 transform_fn == qcms_transform_module_clut_only)) {
 			assert(0 && "Invalid transform");
 			return NULL;
 		}
                 transform->transform_module_fn(transform,src,dest,len);
                 dest = src;
                 src = new_src;
                 transform = transform->next_transform;
         }
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -155,16 +155,17 @@ gfxPlatform *gPlatform = nullptr;
 static bool gEverInitialized = false;
 
 static Mutex* gGfxPlatformPrefsLock = nullptr;
 
 // These two may point to the same profile
 static qcms_profile *gCMSOutputProfile = nullptr;
 static qcms_profile *gCMSsRGBProfile = nullptr;
 
+static bool gCMSRGBTransformFailed = false;
 static qcms_transform *gCMSRGBTransform = nullptr;
 static qcms_transform *gCMSInverseRGBTransform = nullptr;
 static qcms_transform *gCMSRGBATransform = nullptr;
 
 static bool gCMSInitialized = false;
 static eCMSMode gCMSMode = eCMSMode_Off;
 
 static void ShutdownCMS();
@@ -1861,27 +1862,30 @@ gfxPlatform::GetCMSsRGBProfile()
         gCMSsRGBProfile = qcms_profile_sRGB();
     }
     return gCMSsRGBProfile;
 }
 
 qcms_transform *
 gfxPlatform::GetCMSRGBTransform()
 {
-    if (!gCMSRGBTransform) {
+    if (!gCMSRGBTransform && !gCMSRGBTransformFailed) {
         qcms_profile *inProfile, *outProfile;
         outProfile = GetCMSOutputProfile();
         inProfile = GetCMSsRGBProfile();
 
         if (!inProfile || !outProfile)
             return nullptr;
 
         gCMSRGBTransform = qcms_transform_create(inProfile, QCMS_DATA_RGB_8,
                                               outProfile, QCMS_DATA_RGB_8,
                                              QCMS_INTENT_PERCEPTUAL);
+        if (!gCMSRGBTransform) {
+            gCMSRGBTransformFailed = true;
+        }
     }
 
     return gCMSRGBTransform;
 }
 
 qcms_transform *
 gfxPlatform::GetCMSInverseRGBTransform()
 {