Bug 1770766 - Use native AA only for native lines in DrawTargetWebgl. r=aosmond,gfx-reviewers
authorLee Salzman <lsalzman@mozilla.com>
Tue, 24 May 2022 14:40:08 +0000
changeset 618755 63964e5c364dd7a4844a61feab04d72fdf22b37e
parent 618754 def50d42f3743597eeb1f851dce0889cd4cb5c22
child 618756 6ce3dec607ab3de0ae5af8406b789d954cf3e390
push id163393
push userlsalzman@mozilla.com
push dateTue, 24 May 2022 14:42:29 +0000
treeherderautoland@63964e5c364d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaosmond, gfx-reviewers
bugs1770766
milestone102.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 1770766 - Use native AA only for native lines in DrawTargetWebgl. r=aosmond,gfx-reviewers Differential Revision: https://phabricator.services.mozilla.com/D147103
dom/canvas/DrawTargetWebgl.cpp
--- a/dom/canvas/DrawTargetWebgl.cpp
+++ b/dom/canvas/DrawTargetWebgl.cpp
@@ -1388,23 +1388,25 @@ bool DrawTargetWebgl::SharedContext::Dra
       if (mDirtyViewport) {
         float viewportData[2] = {float(mViewportSize.width),
                                  float(mViewportSize.height)};
         mWebgl->UniformData(
             LOCAL_GL_FLOAT_VEC2, mSolidProgramViewport, false,
             {(const uint8_t*)viewportData, sizeof(viewportData)});
         mDirtyViewport = false;
       }
-      if (mDirtyAA) {
-        // AA is not supported for OP_SOURCE.
+      if (mDirtyAA || aStrokeOptions) {
+        // AA is not supported for OP_SOURCE. Native lines use line smoothing.
         float aaData =
-            mLastCompositionOp == CompositionOp::OP_SOURCE ? 0.0f : 1.0f;
+            mLastCompositionOp == CompositionOp::OP_SOURCE || aStrokeOptions
+                ? 0.0f
+                : 1.0f;
         mWebgl->UniformData(LOCAL_GL_FLOAT, mSolidProgramAA, false,
                             {(const uint8_t*)&aaData, sizeof(aaData)});
-        mDirtyAA = false;
+        mDirtyAA = !!aStrokeOptions;
       }
       float a = color.a * aOptions.mAlpha;
       float colorData[4] = {color.b * a, color.g * a, color.r * a, a};
       Matrix xform(aRect.width, 0.0f, 0.0f, aRect.height, aRect.x, aRect.y);
       if (aTransformed) {
         xform *= currentTransform;
       }
       float xformData[6] = {xform._11, xform._12, xform._21,
@@ -1582,23 +1584,25 @@ bool DrawTargetWebgl::SharedContext::Dra
       if (mDirtyViewport) {
         float viewportData[2] = {float(mViewportSize.width),
                                  float(mViewportSize.height)};
         mWebgl->UniformData(
             LOCAL_GL_FLOAT_VEC2, mImageProgramViewport, false,
             {(const uint8_t*)viewportData, sizeof(viewportData)});
         mDirtyViewport = false;
       }
-      if (mDirtyAA) {
-        // AA is not supported for OP_SOURCE.
+      if (mDirtyAA || aStrokeOptions) {
+        // AA is not supported for OP_SOURCE. Native lines use line smoothing.
         float aaData =
-            mLastCompositionOp == CompositionOp::OP_SOURCE ? 0.0f : 1.0f;
+            mLastCompositionOp == CompositionOp::OP_SOURCE || aStrokeOptions
+                ? 0.0f
+                : 1.0f;
         mWebgl->UniformData(LOCAL_GL_FLOAT, mImageProgramAA, false,
                             {(const uint8_t*)&aaData, sizeof(aaData)});
-        mDirtyAA = false;
+        mDirtyAA = !!aStrokeOptions;
       }
       DeviceColor color = aMaskColor.valueOr(DeviceColor(1, 1, 1, 1));
       float a = color.a * aOptions.mAlpha;
       float colorData[4] = {color.b * a, color.g * a, color.r * a, a};
       float swizzleData = aMaskColor ? 1.0f : 0.0f;
       Matrix xform(aRect.width, 0.0f, 0.0f, aRect.height, aRect.x, aRect.y);
       if (aTransformed) {
         xform *= currentTransform;