Bug 1448667 - use ColorMatrix effect instead of LuminanceToAlpha effect for DrawTargetD2D1::IntoLuminanceSource. r=bas
authorLee Salzman <lsalzman@mozilla.com>
Thu, 05 Apr 2018 14:07:18 -0400
changeset 412030 458c07cbe94b9d0ebb03276305ff8d1a6b6f05e1
parent 412029 8cbc541afed7c033595841b0e61811507c66d4c4
child 412031 5ade4a1adeba213daf2edc55061a9a7bad773a03
push id33781
push userapavel@mozilla.com
push dateFri, 06 Apr 2018 14:39:11 +0000
treeherdermozilla-central@6792eee0c9c5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas
bugs1448667
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1448667 - use ColorMatrix effect instead of LuminanceToAlpha effect for DrawTargetD2D1::IntoLuminanceSource. r=bas MozReview-Commit-ID: LHbSiFBx6HK
gfx/2d/DrawTargetD2D1.cpp
layout/reftests/w3c-css/submitted/masking/reftest.list
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -114,23 +114,30 @@ DrawTargetD2D1::Snapshot()
 
 bool
 DrawTargetD2D1::EnsureLuminanceEffect()
 {
   if (mLuminanceEffect.get()) {
     return true;
   }
 
-  HRESULT hr = mDC->CreateEffect(CLSID_D2D1LuminanceToAlpha,
+  HRESULT hr = mDC->CreateEffect(CLSID_D2D1ColorMatrix,
                                  getter_AddRefs(mLuminanceEffect));
   if (FAILED(hr)) {
     gfxCriticalError() << "Failed to create luminance effect. Code: " << hexa(hr);
     return false;
   }
 
+  D2D1_MATRIX_5X4_F matrix = D2D1::Matrix5x4F(0, 0, 0, 0.2125f,
+                                              0, 0, 0, 0.7154f,
+                                              0, 0, 0, 0.0721f,
+                                              0, 0, 0, 0,
+                                              0, 0, 0, 0);
+  mLuminanceEffect->SetValue(D2D1_COLORMATRIX_PROP_COLOR_MATRIX, matrix);
+  mLuminanceEffect->SetValue(D2D1_COLORMATRIX_PROP_ALPHA_MODE, D2D1_COLORMATRIX_ALPHA_MODE_STRAIGHT);
   return true;
 }
 
 already_AddRefed<SourceSurface>
 DrawTargetD2D1::IntoLuminanceSource(LuminanceType aLuminanceType, float aOpacity)
 {
   if ((aLuminanceType != LuminanceType::LUMINANCE) ||
       // See bug 1372577, some race condition where we get invalid
@@ -144,17 +151,17 @@ DrawTargetD2D1::IntoLuminanceSource(Lumi
     return DrawTarget::IntoLuminanceSource(aLuminanceType, aOpacity);
   }
 
   mLuminanceEffect->SetInput(0, mBitmap);
 
   RefPtr<ID2D1Image> luminanceOutput;
   mLuminanceEffect->GetOutput(getter_AddRefs(luminanceOutput));
 
- return MakeAndAddRef<SourceSurfaceD2D1>(luminanceOutput, mDC, SurfaceFormat::A8, mSize);
+ return MakeAndAddRef<SourceSurfaceD2D1>(luminanceOutput, mDC, SurfaceFormat::B8G8R8A8, mSize);
 }
 
 // Command lists are kept around by device contexts until EndDraw is called,
 // this can cause issues with memory usage (see bug 1238328). EndDraw/BeginDraw
 // are expensive though, especially relatively when little work is done, so
 // we try to reduce the amount of times we execute these purges.
 static const uint32_t kPushedLayersBeforePurge = 25;
 
--- a/layout/reftests/w3c-css/submitted/masking/reftest.list
+++ b/layout/reftests/w3c-css/submitted/masking/reftest.list
@@ -23,18 +23,18 @@ random-if(gtkWidget) == mask-image-1c.ht
 == mask-image-1d.html mask-image-1-ref.html
 fuzzy-if(skiaContent||winWidget,1,20000) == mask-image-2.html mask-image-2-ref.html
 == mask-image-3a.html mask-image-3-ref.html
 == mask-image-3b.html mask-image-3-ref.html
 fuzzy-if(skiaContent||winWidget,1,43) == mask-image-3c.html mask-image-3-ref.html
 fuzzy-if(skiaContent||winWidget,1,43) == mask-image-3d.html mask-image-3-ref.html
 == mask-image-3e.html mask-image-3-ref.html
 # Due to SVG luminance, see bug 1372577, parent process doesn't use d2d for luminance.
-fuzzy-if(skiaContent||winWidget,50,85) fuzzy-if(webrender,1,126) fuzzy-if(d2d,255,1) fuzzy-if(winWidget&&!browserIsRemote,50,85) == mask-image-3f.html mask-image-3-ref.html
-fuzzy-if(skiaContent||winWidget,50,85) fuzzy-if(webrender,1,126) fuzzy-if(d2d,255,1) fuzzy-if(winWidget&&!browserIsRemote,50,85) == mask-image-3g.html mask-image-3-ref.html
+fuzzy-if(skiaContent||winWidget,50,85) fuzzy-if(webrender,1,126) == mask-image-3f.html mask-image-3-ref.html
+fuzzy-if(skiaContent||winWidget,50,85) fuzzy-if(webrender,1,126) == mask-image-3g.html mask-image-3-ref.html
 fuzzy-if(winWidget,1,3) fuzzy-if(skiaContent,2,12) == mask-image-3h.html mask-image-3-ref.html
 fuzzy-if(skiaContent,71,203) == mask-image-3i.html mask-image-3-ref.html
 == mask-image-4a.html blank.html
 == mask-image-4b.html blank.html
 == mask-image-5.html mask-image-5-ref.html
 == mask-image-6.html mask-image-6-ref.html
 
 # mask-clip test cases