Bug 1229975 - backport fix for Skia's GrConvexPolyEffect. r=mchang
authorLee Salzman <lsalzman@mozilla.com>
Tue, 29 Mar 2016 22:47:43 -0400
changeset 291009 2b5a3e10e3962289400349e0f0c9f8d3d7b2be8c
parent 291008 7431c1300d28ef1e07f077a92c5db861f9717f72
child 291010 c9670ed4e6c4a4892ceec715176245b8379a15ee
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchang
bugs1229975
milestone48.0a1
Bug 1229975 - backport fix for Skia's GrConvexPolyEffect. r=mchang
gfx/skia/skia/src/gpu/effects/GrConvexPolyEffect.cpp
--- a/gfx/skia/skia/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/gfx/skia/skia/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -3,16 +3,17 @@
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
 
 #include "GrConvexPolyEffect.h"
 #include "GrInvariantOutput.h"
 #include "SkPathPriv.h"
+#include "effects/GrConstColorProcessor.h"
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLFragmentShaderBuilder.h"
 #include "glsl/GrGLSLProgramDataManager.h"
 #include "glsl/GrGLSLUniformHandler.h"
 
 //////////////////////////////////////////////////////////////////////////////
 class AARectEffect : public GrFragmentProcessor {
 public:
@@ -252,17 +253,26 @@ GrFragmentProcessor* GrConvexPolyEffect:
     if (path.countPoints() > kMaxEdges) {
         return nullptr;
     }
 
     SkPoint pts[kMaxEdges];
     SkScalar edges[3 * kMaxEdges];
 
     SkPathPriv::FirstDirection dir;
-    SkAssertResult(SkPathPriv::CheapComputeFirstDirection(path, &dir));
+    // The only way this should fail is if the clip is effectively a infinitely thin line. In that
+    // case nothing is inside the clip. It'd be nice to detect this at a higher level and either
+    // skip the draw or omit the clip element.
+    if (!SkPathPriv::CheapComputeFirstDirection(path, &dir)) {
+        if (GrProcessorEdgeTypeIsInverseFill(type)) {
+            return GrConstColorProcessor::Create(0xFFFFFFFF,
+                                                 GrConstColorProcessor::kModulateRGBA_InputMode);
+        }
+        return GrConstColorProcessor::Create(0, GrConstColorProcessor::kIgnore_InputMode);
+    }
 
     SkVector t;
     if (nullptr == offset) {
         t.set(0, 0);
     } else {
         t = *offset;
     }