Bug 1066673: Change DrawTargetD2D1::DrawSurfaceWithShadow to operate as per Canvas spec. r=jrmuizel
authorBas Schouten <bschouten@mozilla.com>
Sun, 14 Sep 2014 23:51:35 +0200
changeset 719 d166b9e0320da847b131129508693c144cf16e86
parent 718 4dbb4dba171a06e885f93c8221c848cae3a51021
child 720 b100f11163b663481b217576c2d5d988e3bf8843
push id274
push userbschouten@mozilla.com
push dateTue, 23 Sep 2014 16:10:56 +0000
reviewersjrmuizel
bugs1066673
Bug 1066673: Change DrawTargetD2D1::DrawSurfaceWithShadow to operate as per Canvas spec. r=jrmuizel
DrawTargetD2D1.cpp
--- a/DrawTargetD2D1.cpp
+++ b/DrawTargetD2D1.cpp
@@ -175,32 +175,21 @@ DrawTargetD2D1::DrawSurfaceWithShadow(So
   // Step 1, create the shadow effect.
   RefPtr<ID2D1Effect> shadowEffect;
   mDC->CreateEffect(CLSID_D2D1Shadow, byRef(shadowEffect));
   shadowEffect->SetInput(0, image);
   shadowEffect->SetValue(D2D1_SHADOW_PROP_BLUR_STANDARD_DEVIATION, aSigma);
   D2D1_VECTOR_4F color = { aColor.r, aColor.g, aColor.b, aColor.a };
   shadowEffect->SetValue(D2D1_SHADOW_PROP_COLOR, color);
 
-  // Step 2, move the shadow effect into place.
-  RefPtr<ID2D1Effect> affineTransformEffect;
-  mDC->CreateEffect(CLSID_D2D12DAffineTransform, byRef(affineTransformEffect));
-  affineTransformEffect->SetInputEffect(0, shadowEffect);
-  D2D1_MATRIX_3X2_F matrix = D2D1::Matrix3x2F::Translation(aOffset.x, aOffset.y);
-  affineTransformEffect->SetValue(D2D1_2DAFFINETRANSFORM_PROP_TRANSFORM_MATRIX, matrix);
+  D2D1_POINT_2F shadowPoint = D2DPoint(aDest + aOffset);
+  mDC->DrawImage(shadowEffect, &shadowPoint, nullptr, D2D1_INTERPOLATION_MODE_LINEAR, D2DCompositionMode(aOperator));
 
-  // Step 3, create an effect that combines shadow and bitmap in one image.
-  RefPtr<ID2D1Effect> compositeEffect;
-  mDC->CreateEffect(CLSID_D2D1Composite, byRef(compositeEffect));
-  compositeEffect->SetInputEffect(0, affineTransformEffect);
-  compositeEffect->SetInput(1, image);
-  compositeEffect->SetValue(D2D1_COMPOSITE_PROP_MODE, D2DCompositionMode(aOperator));
-
-  D2D1_POINT_2F surfPoint = D2DPoint(aDest);
-  mDC->DrawImage(compositeEffect, &surfPoint, nullptr, D2D1_INTERPOLATION_MODE_LINEAR, D2DCompositionMode(aOperator));
+  D2D1_POINT_2F imgPoint = D2DPoint(aDest);
+  mDC->DrawImage(image, &imgPoint, nullptr, D2D1_INTERPOLATION_MODE_LINEAR, D2DCompositionMode(aOperator));
 }
 
 void
 DrawTargetD2D1::ClearRect(const Rect &aRect)
 {
   MarkChanged();
 
   PopAllClips();