#include "src/gpu/ganesh/ops/DashOp.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPathEffect.h"
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
#include "include/core/SkString.h"
#include "include/core/SkStrokeRec.h"
#include "include/gpu/ganesh/GrRecordingContext.h"
#include "include/private/SkColorData.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkPoint_impl.h"
#include "include/private/base/SkTArray.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/base/SkArenaAlloc.h"
#include "src/base/SkSafeMath.h"
#include "src/core/SkMatrixPriv.h"
#include "src/core/SkPointPriv.h"
#include "src/core/SkSLTypeShared.h"
#include "src/gpu/BufferWriter.h"
#include "src/gpu/KeyBuilder.h"
#include "src/gpu/ganesh/GrAppliedClip.h"
#include "src/gpu/ganesh/GrColor.h"
#include "src/gpu/ganesh/GrDefaultGeoProcFactory.h"
#include "src/gpu/ganesh/GrGeometryProcessor.h"
#include "src/gpu/ganesh/GrOpFlushState.h"
#include "src/gpu/ganesh/GrPaint.h"
#include "src/gpu/ganesh/GrPipeline.h"
#include "src/gpu/ganesh/GrProcessorAnalysis.h"
#include "src/gpu/ganesh/GrProcessorSet.h"
#include "src/gpu/ganesh/GrProcessorUnitTest.h"
#include "src/gpu/ganesh/GrProgramInfo.h"
#include "src/gpu/ganesh/GrStyle.h"
#include "src/gpu/ganesh/GrUserStencilSettings.h"
#include "src/gpu/ganesh/geometry/GrQuad.h"
#include "src/gpu/ganesh/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/ganesh/glsl/GrGLSLProgramDataManager.h"
#include "src/gpu/ganesh/glsl/GrGLSLVarying.h"
#include "src/gpu/ganesh/glsl/GrGLSLVertexGeoBuilder.h"
#include "src/gpu/ganesh/ops/GrDrawOp.h"
#include "src/gpu/ganesh/ops/GrMeshDrawOp.h"
#include "src/gpu/ganesh/ops/GrSimpleMeshDrawOpHelper.h"
#if defined(GPU_TEST_UTILS)
#include "src/base/SkRandom.h"
#include "src/gpu/ganesh/GrDrawOpTest.h"
#include "src/gpu/ganesh/GrTestUtils.h"
#endif
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <memory>
#include <utility>
class GrCaps;
class GrDstProxyView;
class GrGLSLUniformHandler;
class GrMeshDrawTarget;
class GrSurfaceProxyView;
enum class GrXferBarrierFlags;
struct GrShaderCaps;
struct GrSimpleMesh;
namespace skgpu {
namespace ganesh {
class SurfaceDrawContext;
}
}
usingnamespaceskia_private;
AAMode;
#if defined(GPU_TEST_UTILS)
constexpr int kAAModeCnt = static_cast<int>(skgpu::ganesh::DashOp::AAMode::kCoverageWithMSAA) + 1;
#endif
namespace skgpu::ganesh::DashOp {
namespace …
GrOp::Owner MakeDashLineOp(GrRecordingContext* context,
GrPaint&& paint,
const SkMatrix& viewMatrix,
const SkPoint pts[2],
AAMode aaMode,
const GrStyle& style,
const GrUserStencilSettings* stencilSettings) { … }
bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style, const SkMatrix& viewMatrix) { … }
}
#if defined(GPU_TEST_UTILS)
GR_DRAW_OP_TEST_DEFINE(DashOpImpl) {
SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random);
AAMode aaMode;
do {
aaMode = static_cast<AAMode>(random->nextULessThan(kAAModeCnt));
} while (AAMode::kCoverageWithMSAA == aaMode && numSamples <= 1);
SkPoint pts[2];
if (random->nextBool()) {
pts[0].fX = 1.f;
pts[0].fY = random->nextF() * 10.f;
pts[1].fX = 1.f;
pts[1].fY = random->nextF() * 10.f;
} else {
pts[0].fX = random->nextF() * 10.f;
pts[0].fY = 1.f;
pts[1].fX = random->nextF() * 10.f;
pts[1].fY = 1.f;
}
SkPaint::Cap cap = SkPaint::Cap(random->nextULessThan(SkPaint::kCapCount));
SkScalar intervals[2];
enum Intervals {
kOpenOpen_Intervals ,
kOpenClose_Intervals,
kCloseOpen_Intervals,
};
Intervals intervalType = SkPaint::kRound_Cap == cap ?
kOpenClose_Intervals :
Intervals(random->nextULessThan(kCloseOpen_Intervals + 1));
static const SkScalar kIntervalMin = 0.1f;
static const SkScalar kIntervalMinCircles = 1.f;
static const SkScalar kIntervalMax = 10.f;
switch (intervalType) {
case kOpenOpen_Intervals:
intervals[0] = random->nextRangeScalar(kIntervalMin, kIntervalMax);
intervals[1] = random->nextRangeScalar(kIntervalMin, kIntervalMax);
break;
case kOpenClose_Intervals: {
intervals[0] = 0.f;
SkScalar min = SkPaint::kRound_Cap == cap ? kIntervalMinCircles : kIntervalMin;
intervals[1] = random->nextRangeScalar(min, kIntervalMax);
break;
}
case kCloseOpen_Intervals:
intervals[0] = random->nextRangeScalar(kIntervalMin, kIntervalMax);
intervals[1] = 0.f;
break;
}
SkScalar phase = random->nextRangeScalar(0, intervals[0] + intervals[1]);
SkPaint p;
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(SkIntToScalar(1));
p.setStrokeCap(cap);
p.setPathEffect(GrTest::TestDashPathEffect::Make(intervals, 2, phase));
GrStyle style(p);
return skgpu::ganesh::DashOp::MakeDashLineOp(context, std::move(paint), viewMatrix, pts, aaMode,
style, GrGetRandomStencil(random, context));
}
#endif