Revert "converted AARectEffect to new FP system"
This reverts commit 222e275b0ab4c8a2af152c637bf9dbc28b4a097f.
Reason for revert: perf regression
Original change's description:
> converted AARectEffect to new FP system
>
> Bug: skia:
> Change-Id: I0e4141c7f547bab92c65a6abff120ed04d5c2c66
> Reviewed-on: https://skia-review.googlesource.com/c/153550
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
TBR=bsalomon@google.com,ethannicholas@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: skia:
Change-Id: I3d7036a78d8582d6790c77b20a60e6e5257d1881
Reviewed-on: https://skia-review.googlesource.com/c/162283
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index a0440f0..4751fec 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -7,52 +7,13 @@
#include "GrConvexPolyEffect.h"
#include "SkPathPriv.h"
+#include "effects/GrAARectEffect.h"
#include "effects/GrConstColorProcessor.h"
-#include "effects/GrSkSLFP.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
-GR_FP_SRC_STRING SKSL_AARECT_SRC = R"(
-layout(key) in GrClipEdgeType edgeType;
-layout(ctype=SkRect) in float4 rect;
-uniform float4 rectUniform;
-
-void main(int x, int y, inout half4 color) {
- half alpha;
- @switch (edgeType) {
- case GrClipEdgeType::kFillBW: // fall through
- case GrClipEdgeType::kInverseFillBW:
- // non-AA
- alpha = all(greaterThan(float4(x, y, rectUniform.zw),
- float4(rectUniform.xy, x, y))) ? 1 : 0;
- break;
- default:
- // The amount of coverage removed in x and y by the edges is computed as a pair of
- // negative numbers, xSub and ySub.
- half xSub, ySub;
- xSub = min(x - rectUniform.x, 0.0);
- xSub += min(rectUniform.z - x, 0.0);
- ySub = min(y - rectUniform.y, 0.0);
- ySub += min(rectUniform.w - y, 0.0);
- // Now compute coverage in x and y and multiply them to get the fraction of the pixel
- // covered.
- alpha = (1.0 + max(xSub, -1.0)) * (1.0 + max(ySub, -1.0));
- }
-
- @if (edgeType == GrClipEdgeType::kInverseFillBW || edgeType == GrClipEdgeType::kInverseFillAA) {
- alpha = 1.0 - alpha;
- }
- color *= alpha;
-}
-)";
-
-struct AARectInputs {
- GrClipEdgeType fEdgeType;
- SkRect fRect;
-};
-
//////////////////////////////////////////////////////////////////////////////
class GrGLConvexPolyEffect : public GrGLSLFragmentProcessor {
@@ -127,8 +88,7 @@
//////////////////////////////////////////////////////////////////////////////
std::unique_ptr<GrFragmentProcessor> GrConvexPolyEffect::Make(GrClipEdgeType type,
- const SkPath& path,
- GrContext* context) {
+ const SkPath& path) {
if (GrClipEdgeType::kHairlineAA == type) {
return nullptr;
}
@@ -198,34 +158,12 @@
return Make(type, n, edges);
}
-static void aa_rect_set_data_hook(const GrGLSLProgramDataManager& pdman,
- const GrGLSLSkSLFP& glslProc,
- const AARectInputs& inputs,
- SkRect* prevRect) {
- if (inputs.fRect != *prevRect) {
- const SkRect& newRect = GrProcessorEdgeTypeIsAA(inputs.fEdgeType) ?
- inputs.fRect.makeInset(.5f, .5f) : inputs.fRect;
- pdman.set4f(glslProc.uniformHandle(0), newRect.fLeft, newRect.fTop, newRect.fRight,
- newRect.fBottom);
- *prevRect = inputs.fRect;
- }
-}
-
std::unique_ptr<GrFragmentProcessor> GrConvexPolyEffect::Make(GrClipEdgeType edgeType,
- const SkRect& rect,
- GrContext* context) {
+ const SkRect& rect) {
if (GrClipEdgeType::kHairlineAA == edgeType){
return nullptr;
}
- static int aaRectIndex = GrSkSLFP::NewIndex();
- AARectInputs inputs;
- inputs.fEdgeType = edgeType;
- inputs.fRect = rect;
- std::unique_ptr<GrSkSLFP> result = GrSkSLFP::Make(context, aaRectIndex, "AARect",
- SKSL_AARECT_SRC, inputs,
- SkRect::MakeXYWH(-1, -1, -1, -1),
- aa_rect_set_data_hook);
- return std::unique_ptr<GrFragmentProcessor>(result.release());
+ return GrAARectEffect::Make(edgeType, rect);
}
GrConvexPolyEffect::~GrConvexPolyEffect() {}