Move more Ops to skgpu::v1 namespace (take 2)
GrClearOp GrDashOp Bug: skia:11837 Change-Id: I9ada76c061154e769e7f486e7c57a93fd1d74907 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/444636 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
2af13c135b
commit
46d7bd56f6
@ -507,8 +507,12 @@ skia_skgpu_v1_sources = [
|
|||||||
"$_src/gpu/ops/AtlasRenderTask.h",
|
"$_src/gpu/ops/AtlasRenderTask.h",
|
||||||
"$_src/gpu/ops/AtlasTextOp.cpp",
|
"$_src/gpu/ops/AtlasTextOp.cpp",
|
||||||
"$_src/gpu/ops/AtlasTextOp.h",
|
"$_src/gpu/ops/AtlasTextOp.h",
|
||||||
|
"$_src/gpu/ops/ClearOp.cpp",
|
||||||
|
"$_src/gpu/ops/ClearOp.h",
|
||||||
"$_src/gpu/ops/DashLinePathRenderer.cpp",
|
"$_src/gpu/ops/DashLinePathRenderer.cpp",
|
||||||
"$_src/gpu/ops/DashLinePathRenderer.h",
|
"$_src/gpu/ops/DashLinePathRenderer.h",
|
||||||
|
"$_src/gpu/ops/DashOp.cpp",
|
||||||
|
"$_src/gpu/ops/DashOp.h",
|
||||||
"$_src/gpu/ops/DefaultPathRenderer.cpp",
|
"$_src/gpu/ops/DefaultPathRenderer.cpp",
|
||||||
"$_src/gpu/ops/DefaultPathRenderer.h",
|
"$_src/gpu/ops/DefaultPathRenderer.h",
|
||||||
"$_src/gpu/ops/DrawAtlasOp.cpp",
|
"$_src/gpu/ops/DrawAtlasOp.cpp",
|
||||||
@ -519,10 +523,6 @@ skia_skgpu_v1_sources = [
|
|||||||
"$_src/gpu/ops/DrawableOp.h",
|
"$_src/gpu/ops/DrawableOp.h",
|
||||||
"$_src/gpu/ops/GrAtlasInstancedHelper.cpp",
|
"$_src/gpu/ops/GrAtlasInstancedHelper.cpp",
|
||||||
"$_src/gpu/ops/GrAtlasInstancedHelper.h",
|
"$_src/gpu/ops/GrAtlasInstancedHelper.h",
|
||||||
"$_src/gpu/ops/GrClearOp.cpp",
|
|
||||||
"$_src/gpu/ops/GrClearOp.h",
|
|
||||||
"$_src/gpu/ops/GrDashOp.cpp",
|
|
||||||
"$_src/gpu/ops/GrDashOp.h",
|
|
||||||
"$_src/gpu/ops/GrDrawAtlasPathOp.cpp",
|
"$_src/gpu/ops/GrDrawAtlasPathOp.cpp",
|
||||||
"$_src/gpu/ops/GrDrawAtlasPathOp.h",
|
"$_src/gpu/ops/GrDrawAtlasPathOp.h",
|
||||||
"$_src/gpu/ops/GrDrawOp.h",
|
"$_src/gpu/ops/GrDrawOp.h",
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "src/gpu/ops/GrClearOp.h"
|
#include "src/gpu/ops/ClearOp.h"
|
||||||
|
|
||||||
#include "include/gpu/GrRecordingContext.h"
|
#include "include/gpu/GrRecordingContext.h"
|
||||||
#include "src/gpu/GrMemoryPool.h"
|
#include "src/gpu/GrMemoryPool.h"
|
||||||
@ -14,31 +14,37 @@
|
|||||||
#include "src/gpu/GrProxyProvider.h"
|
#include "src/gpu/GrProxyProvider.h"
|
||||||
#include "src/gpu/GrRecordingContextPriv.h"
|
#include "src/gpu/GrRecordingContextPriv.h"
|
||||||
|
|
||||||
static bool contains_scissor(const GrScissorState& a, const GrScissorState& b) {
|
namespace {
|
||||||
|
|
||||||
|
bool contains_scissor(const GrScissorState& a, const GrScissorState& b) {
|
||||||
return !a.enabled() || (b.enabled() && a.rect().contains(b.rect()));
|
return !a.enabled() || (b.enabled() && a.rect().contains(b.rect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
GrOp::Owner GrClearOp::MakeColor(GrRecordingContext* context,
|
} // anonymous namespace
|
||||||
const GrScissorState& scissor,
|
|
||||||
std::array<float, 4> color) {
|
namespace skgpu::v1 {
|
||||||
return GrOp::Make<GrClearOp>(context, Buffer::kColor, scissor, color, false);
|
|
||||||
|
GrOp::Owner ClearOp::MakeColor(GrRecordingContext* context,
|
||||||
|
const GrScissorState& scissor,
|
||||||
|
std::array<float, 4> color) {
|
||||||
|
return GrOp::Make<ClearOp>(context, Buffer::kColor, scissor, color, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
GrOp::Owner GrClearOp::MakeStencilClip(GrRecordingContext* context,
|
GrOp::Owner ClearOp::MakeStencilClip(GrRecordingContext* context,
|
||||||
const GrScissorState& scissor,
|
const GrScissorState& scissor,
|
||||||
bool insideMask) {
|
bool insideMask) {
|
||||||
return GrOp::Make<GrClearOp>(context,
|
return GrOp::Make<ClearOp>(context,
|
||||||
Buffer::kStencilClip,
|
Buffer::kStencilClip,
|
||||||
scissor,
|
scissor,
|
||||||
std::array<float, 4>(),
|
std::array<float, 4>(),
|
||||||
insideMask);
|
insideMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
GrClearOp::GrClearOp(Buffer buffer,
|
ClearOp::ClearOp(Buffer buffer,
|
||||||
const GrScissorState& scissor,
|
const GrScissorState& scissor,
|
||||||
std::array<float, 4> color,
|
std::array<float, 4> color,
|
||||||
bool insideMask)
|
bool insideMask)
|
||||||
: INHERITED(ClassID())
|
: GrOp(ClassID())
|
||||||
, fScissor(scissor)
|
, fScissor(scissor)
|
||||||
, fColor(color)
|
, fColor(color)
|
||||||
, fStencilInsideMask(insideMask)
|
, fStencilInsideMask(insideMask)
|
||||||
@ -46,8 +52,8 @@ GrClearOp::GrClearOp(Buffer buffer,
|
|||||||
this->setBounds(SkRect::Make(scissor.rect()), HasAABloat::kNo, IsHairline::kNo);
|
this->setBounds(SkRect::Make(scissor.rect()), HasAABloat::kNo, IsHairline::kNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
GrOp::CombineResult GrClearOp::onCombineIfPossible(GrOp* t, SkArenaAlloc*, const GrCaps& caps) {
|
GrOp::CombineResult ClearOp::onCombineIfPossible(GrOp* t, SkArenaAlloc*, const GrCaps& caps) {
|
||||||
GrClearOp* other = t->cast<GrClearOp>();
|
auto other = t->cast<ClearOp>();
|
||||||
|
|
||||||
if (other->fBuffer == fBuffer) {
|
if (other->fBuffer == fBuffer) {
|
||||||
// This could be much more complicated. Currently we look at cases where the new clear
|
// This could be much more complicated. Currently we look at cases where the new clear
|
||||||
@ -77,7 +83,7 @@ GrOp::CombineResult GrClearOp::onCombineIfPossible(GrOp* t, SkArenaAlloc*, const
|
|||||||
return CombineResult::kCannotCombine;
|
return CombineResult::kCannotCombine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrClearOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
|
void ClearOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
|
||||||
SkASSERT(state->opsRenderPass());
|
SkASSERT(state->opsRenderPass());
|
||||||
if (fBuffer & Buffer::kColor) {
|
if (fBuffer & Buffer::kColor) {
|
||||||
state->opsRenderPass()->clear(fScissor, fColor);
|
state->opsRenderPass()->clear(fScissor, fColor);
|
||||||
@ -87,3 +93,6 @@ void GrClearOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
|
|||||||
state->opsRenderPass()->clearStencilClip(fScissor, fStencilInsideMask);
|
state->opsRenderPass()->clearStencilClip(fScissor, fStencilInsideMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace skgpu::v1
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GrClearOp_DEFINED
|
#ifndef ClearOp_DEFINED
|
||||||
#define GrClearOp_DEFINED
|
#define ClearOp_DEFINED
|
||||||
|
|
||||||
#include "include/gpu/GrTypes.h"
|
#include "include/gpu/GrTypes.h"
|
||||||
#include "src/gpu/GrScissorState.h"
|
#include "src/gpu/GrScissorState.h"
|
||||||
@ -15,7 +15,9 @@
|
|||||||
class GrOpFlushState;
|
class GrOpFlushState;
|
||||||
class GrRecordingContext;
|
class GrRecordingContext;
|
||||||
|
|
||||||
class GrClearOp final : public GrOp {
|
namespace skgpu::v1 {
|
||||||
|
|
||||||
|
class ClearOp final : public GrOp {
|
||||||
public:
|
public:
|
||||||
DEFINE_OP_CLASS_ID
|
DEFINE_OP_CLASS_ID
|
||||||
|
|
||||||
@ -43,10 +45,10 @@ private:
|
|||||||
};
|
};
|
||||||
GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(Buffer);
|
GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(Buffer);
|
||||||
|
|
||||||
GrClearOp(Buffer buffer,
|
ClearOp(Buffer buffer,
|
||||||
const GrScissorState& scissor,
|
const GrScissorState& scissor,
|
||||||
std::array<float, 4> color,
|
std::array<float, 4> color,
|
||||||
bool stencil);
|
bool stencil);
|
||||||
|
|
||||||
CombineResult onCombineIfPossible(GrOp* t, SkArenaAlloc*, const GrCaps& caps) override;
|
CombineResult onCombineIfPossible(GrOp* t, SkArenaAlloc*, const GrCaps& caps) override;
|
||||||
|
|
||||||
@ -75,10 +77,10 @@ private:
|
|||||||
std::array<float, 4> fColor;
|
std::array<float, 4> fColor;
|
||||||
bool fStencilInsideMask;
|
bool fStencilInsideMask;
|
||||||
Buffer fBuffer;
|
Buffer fBuffer;
|
||||||
|
|
||||||
using INHERITED = GrOp;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GR_MAKE_BITFIELD_CLASS_OPS(GrClearOp::Buffer)
|
GR_MAKE_BITFIELD_CLASS_OPS(ClearOp::Buffer)
|
||||||
|
|
||||||
#endif
|
} // namespace skgpu::v1
|
||||||
|
|
||||||
|
#endif // ClearOp_DEFINED
|
@ -10,7 +10,7 @@
|
|||||||
#include "src/gpu/GrAuditTrail.h"
|
#include "src/gpu/GrAuditTrail.h"
|
||||||
#include "src/gpu/GrGpu.h"
|
#include "src/gpu/GrGpu.h"
|
||||||
#include "src/gpu/geometry/GrStyledShape.h"
|
#include "src/gpu/geometry/GrStyledShape.h"
|
||||||
#include "src/gpu/ops/GrDashOp.h"
|
#include "src/gpu/ops/DashOp.h"
|
||||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ PathRenderer::CanDrawPath DashLinePathRenderer::onCanDrawPath(const CanDrawPathA
|
|||||||
if (args.fShape->style().isDashed() && args.fShape->asLine(pts, &inverted)) {
|
if (args.fShape->style().isDashed() && args.fShape->asLine(pts, &inverted)) {
|
||||||
// We should never have an inverse dashed case.
|
// We should never have an inverse dashed case.
|
||||||
SkASSERT(!inverted);
|
SkASSERT(!inverted);
|
||||||
if (!GrDashOp::CanDrawDashLine(pts, args.fShape->style(), *args.fViewMatrix)) {
|
if (!DashOp::CanDrawDashLine(pts, args.fShape->style(), *args.fViewMatrix)) {
|
||||||
return CanDrawPath::kNo;
|
return CanDrawPath::kNo;
|
||||||
}
|
}
|
||||||
return CanDrawPath::kYes;
|
return CanDrawPath::kYes;
|
||||||
@ -33,25 +33,25 @@ PathRenderer::CanDrawPath DashLinePathRenderer::onCanDrawPath(const CanDrawPathA
|
|||||||
bool DashLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
bool DashLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(),
|
GR_AUDIT_TRAIL_AUTO_FRAME(args.fContext->priv().auditTrail(),
|
||||||
"DashLinePathRenderer::onDrawPath");
|
"DashLinePathRenderer::onDrawPath");
|
||||||
GrDashOp::AAMode aaMode;
|
DashOp::AAMode aaMode;
|
||||||
switch (args.fAAType) {
|
switch (args.fAAType) {
|
||||||
case GrAAType::kNone:
|
case GrAAType::kNone:
|
||||||
aaMode = GrDashOp::AAMode::kNone;
|
aaMode = DashOp::AAMode::kNone;
|
||||||
break;
|
break;
|
||||||
case GrAAType::kMSAA:
|
case GrAAType::kMSAA:
|
||||||
// In this mode we will use aa between dashes but the outer border uses MSAA. Otherwise,
|
// In this mode we will use aa between dashes but the outer border uses MSAA. Otherwise,
|
||||||
// we can wind up with external edges antialiased and internal edges unantialiased.
|
// we can wind up with external edges antialiased and internal edges unantialiased.
|
||||||
aaMode = GrDashOp::AAMode::kCoverageWithMSAA;
|
aaMode = DashOp::AAMode::kCoverageWithMSAA;
|
||||||
break;
|
break;
|
||||||
case GrAAType::kCoverage:
|
case GrAAType::kCoverage:
|
||||||
aaMode = GrDashOp::AAMode::kCoverage;
|
aaMode = DashOp::AAMode::kCoverage;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SkPoint pts[2];
|
SkPoint pts[2];
|
||||||
SkAssertResult(args.fShape->asLine(pts, nullptr));
|
SkAssertResult(args.fShape->asLine(pts, nullptr));
|
||||||
GrOp::Owner op =
|
GrOp::Owner op = DashOp::MakeDashLineOp(args.fContext, std::move(args.fPaint),
|
||||||
GrDashOp::MakeDashLineOp(args.fContext, std::move(args.fPaint), *args.fViewMatrix, pts,
|
*args.fViewMatrix, pts, aaMode, args.fShape->style(),
|
||||||
aaMode, args.fShape->style(), args.fUserStencilSettings);
|
args.fUserStencilSettings);
|
||||||
if (!op) {
|
if (!op) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "src/gpu/ops/GrDashOp.h"
|
#include "src/gpu/ops/DashOp.h"
|
||||||
|
|
||||||
#include "include/gpu/GrRecordingContext.h"
|
#include "include/gpu/GrRecordingContext.h"
|
||||||
#include "src/core/SkMatrixPriv.h"
|
#include "src/core/SkMatrixPriv.h"
|
||||||
@ -13,7 +13,6 @@
|
|||||||
#include "src/gpu/GrAppliedClip.h"
|
#include "src/gpu/GrAppliedClip.h"
|
||||||
#include "src/gpu/GrCaps.h"
|
#include "src/gpu/GrCaps.h"
|
||||||
#include "src/gpu/GrDefaultGeoProcFactory.h"
|
#include "src/gpu/GrDefaultGeoProcFactory.h"
|
||||||
#include "src/gpu/GrDrawOpTest.h"
|
|
||||||
#include "src/gpu/GrGeometryProcessor.h"
|
#include "src/gpu/GrGeometryProcessor.h"
|
||||||
#include "src/gpu/GrMemoryPool.h"
|
#include "src/gpu/GrMemoryPool.h"
|
||||||
#include "src/gpu/GrOpFlushState.h"
|
#include "src/gpu/GrOpFlushState.h"
|
||||||
@ -32,51 +31,16 @@
|
|||||||
#include "src/gpu/ops/GrMeshDrawOp.h"
|
#include "src/gpu/ops/GrMeshDrawOp.h"
|
||||||
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
|
#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
|
||||||
|
|
||||||
using AAMode = GrDashOp::AAMode;
|
using AAMode = skgpu::v1::DashOp::AAMode;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
#if GR_TEST_UTILS
|
||||||
|
static const int kAAModeCnt = static_cast<int>(skgpu::v1::DashOp::AAMode::kCoverageWithMSAA) + 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Returns whether or not the gpu can fast path the dash line effect.
|
namespace {
|
||||||
bool GrDashOp::CanDrawDashLine(const SkPoint pts[2], const GrStyle& style,
|
|
||||||
const SkMatrix& viewMatrix) {
|
|
||||||
// Pts must be either horizontal or vertical in src space
|
|
||||||
if (pts[0].fX != pts[1].fX && pts[0].fY != pts[1].fY) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// May be able to relax this to include skew. As of now cannot do perspective
|
void calc_dash_scaling(SkScalar* parallelScale, SkScalar* perpScale,
|
||||||
// because of the non uniform scaling of bloating a rect
|
const SkMatrix& viewMatrix, const SkPoint pts[2]) {
|
||||||
if (!viewMatrix.preservesRightAngles()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!style.isDashed() || 2 != style.dashIntervalCnt()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const SkScalar* intervals = style.dashIntervals();
|
|
||||||
if (0 == intervals[0] && 0 == intervals[1]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkPaint::Cap cap = style.strokeRec().getCap();
|
|
||||||
if (SkPaint::kRound_Cap == cap) {
|
|
||||||
// Current we don't support round caps unless the on interval is zero
|
|
||||||
if (intervals[0] != 0.f) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// If the width of the circle caps in greater than the off interval we will pick up unwanted
|
|
||||||
// segments of circles at the start and end of the dash line.
|
|
||||||
if (style.strokeRec().getWidth() > intervals[1]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void calc_dash_scaling(SkScalar* parallelScale, SkScalar* perpScale,
|
|
||||||
const SkMatrix& viewMatrix, const SkPoint pts[2]) {
|
|
||||||
SkVector vecSrc = pts[1] - pts[0];
|
SkVector vecSrc = pts[1] - pts[0];
|
||||||
if (pts[1] == pts[0]) {
|
if (pts[1] == pts[0]) {
|
||||||
vecSrc.set(1.0, 0.0);
|
vecSrc.set(1.0, 0.0);
|
||||||
@ -98,7 +62,7 @@ static void calc_dash_scaling(SkScalar* parallelScale, SkScalar* perpScale,
|
|||||||
|
|
||||||
// calculates the rotation needed to aligned pts to the x axis with pts[0] < pts[1]
|
// calculates the rotation needed to aligned pts to the x axis with pts[0] < pts[1]
|
||||||
// Stores the rotation matrix in rotMatrix, and the mapped points in ptsRot
|
// Stores the rotation matrix in rotMatrix, and the mapped points in ptsRot
|
||||||
static void align_to_x_axis(const SkPoint pts[2], SkMatrix* rotMatrix, SkPoint ptsRot[2] = nullptr) {
|
void align_to_x_axis(const SkPoint pts[2], SkMatrix* rotMatrix, SkPoint ptsRot[2] = nullptr) {
|
||||||
SkVector vec = pts[1] - pts[0];
|
SkVector vec = pts[1] - pts[0];
|
||||||
if (pts[1] == pts[0]) {
|
if (pts[1] == pts[0]) {
|
||||||
vec.set(1.0, 0.0);
|
vec.set(1.0, 0.0);
|
||||||
@ -116,7 +80,7 @@ static void align_to_x_axis(const SkPoint pts[2], SkMatrix* rotMatrix, SkPoint p
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assumes phase < sum of all intervals
|
// Assumes phase < sum of all intervals
|
||||||
static SkScalar calc_start_adjustment(const SkScalar intervals[2], SkScalar phase) {
|
SkScalar calc_start_adjustment(const SkScalar intervals[2], SkScalar phase) {
|
||||||
SkASSERT(phase < intervals[0] + intervals[1]);
|
SkASSERT(phase < intervals[0] + intervals[1]);
|
||||||
if (phase >= intervals[0] && phase != 0) {
|
if (phase >= intervals[0] && phase != 0) {
|
||||||
SkScalar srcIntervalLen = intervals[0] + intervals[1];
|
SkScalar srcIntervalLen = intervals[0] + intervals[1];
|
||||||
@ -125,8 +89,8 @@ static SkScalar calc_start_adjustment(const SkScalar intervals[2], SkScalar phas
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SkScalar calc_end_adjustment(const SkScalar intervals[2], const SkPoint pts[2],
|
SkScalar calc_end_adjustment(const SkScalar intervals[2], const SkPoint pts[2],
|
||||||
SkScalar phase, SkScalar* endingInt) {
|
SkScalar phase, SkScalar* endingInt) {
|
||||||
if (pts[1].fX <= pts[0].fX) {
|
if (pts[1].fX <= pts[0].fX) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -151,17 +115,17 @@ enum DashCap {
|
|||||||
kNonRound_DashCap,
|
kNonRound_DashCap,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void setup_dashed_rect(const SkRect& rect,
|
void setup_dashed_rect(const SkRect& rect,
|
||||||
GrVertexWriter& vertices,
|
GrVertexWriter& vertices,
|
||||||
const SkMatrix& matrix,
|
const SkMatrix& matrix,
|
||||||
SkScalar offset,
|
SkScalar offset,
|
||||||
SkScalar bloatX,
|
SkScalar bloatX,
|
||||||
SkScalar len,
|
SkScalar len,
|
||||||
SkScalar startInterval,
|
SkScalar startInterval,
|
||||||
SkScalar endInterval,
|
SkScalar endInterval,
|
||||||
SkScalar strokeWidth,
|
SkScalar strokeWidth,
|
||||||
SkScalar perpScale,
|
SkScalar perpScale,
|
||||||
DashCap cap) {
|
DashCap cap) {
|
||||||
SkScalar intervalLength = startInterval + endInterval;
|
SkScalar intervalLength = startInterval + endInterval;
|
||||||
// 'dashRect' gets interpolated over the rendered 'rect'. For y we want the perpendicular signed
|
// 'dashRect' gets interpolated over the rendered 'rect'. For y we want the perpendicular signed
|
||||||
// distance from the stroke center line in device space. 'perpScale' is the scale factor applied
|
// distance from the stroke center line in device space. 'perpScale' is the scale factor applied
|
||||||
@ -200,14 +164,14 @@ static void setup_dashed_rect(const SkRect& rect,
|
|||||||
* Bounding geometry is rendered and the effect computes coverage based on the fragment's
|
* Bounding geometry is rendered and the effect computes coverage based on the fragment's
|
||||||
* position relative to the dashed line.
|
* position relative to the dashed line.
|
||||||
*/
|
*/
|
||||||
static GrGeometryProcessor* make_dash_gp(SkArenaAlloc* arena,
|
GrGeometryProcessor* make_dash_gp(SkArenaAlloc* arena,
|
||||||
const SkPMColor4f&,
|
const SkPMColor4f&,
|
||||||
AAMode aaMode,
|
AAMode aaMode,
|
||||||
DashCap cap,
|
DashCap cap,
|
||||||
const SkMatrix& localMatrix,
|
const SkMatrix& localMatrix,
|
||||||
bool usesLocalCoords);
|
bool usesLocalCoords);
|
||||||
|
|
||||||
class DashOp final : public GrMeshDrawOp {
|
class DashOpImpl final : public GrMeshDrawOp {
|
||||||
public:
|
public:
|
||||||
DEFINE_OP_CLASS_ID
|
DEFINE_OP_CLASS_ID
|
||||||
|
|
||||||
@ -228,8 +192,8 @@ public:
|
|||||||
SkPaint::Cap cap,
|
SkPaint::Cap cap,
|
||||||
AAMode aaMode, bool fullDash,
|
AAMode aaMode, bool fullDash,
|
||||||
const GrUserStencilSettings* stencilSettings) {
|
const GrUserStencilSettings* stencilSettings) {
|
||||||
return GrOp::Make<DashOp>(context, std::move(paint), geometry, cap,
|
return GrOp::Make<DashOpImpl>(context, std::move(paint), geometry, cap,
|
||||||
aaMode, fullDash, stencilSettings);
|
aaMode, fullDash, stencilSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* name() const override { return "DashOp"; }
|
const char* name() const override { return "DashOp"; }
|
||||||
@ -265,8 +229,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
friend class GrOp; // for ctor
|
friend class GrOp; // for ctor
|
||||||
|
|
||||||
DashOp(GrPaint&& paint, const LineData& geometry, SkPaint::Cap cap, AAMode aaMode,
|
DashOpImpl(GrPaint&& paint, const LineData& geometry, SkPaint::Cap cap, AAMode aaMode,
|
||||||
bool fullDash, const GrUserStencilSettings* stencilSettings)
|
bool fullDash, const GrUserStencilSettings* stencilSettings)
|
||||||
: INHERITED(ClassID())
|
: INHERITED(ClassID())
|
||||||
, fColor(paint.getColor4f())
|
, fColor(paint.getColor4f())
|
||||||
, fFullDash(fullDash)
|
, fFullDash(fullDash)
|
||||||
@ -661,7 +625,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
CombineResult onCombineIfPossible(GrOp* t, SkArenaAlloc*, const GrCaps& caps) override {
|
CombineResult onCombineIfPossible(GrOp* t, SkArenaAlloc*, const GrCaps& caps) override {
|
||||||
DashOp* that = t->cast<DashOp>();
|
auto that = t->cast<DashOpImpl>();
|
||||||
if (fProcessorSet != that->fProcessorSet) {
|
if (fProcessorSet != that->fProcessorSet) {
|
||||||
return CombineResult::kCannotCombine;
|
return CombineResult::kCannotCombine;
|
||||||
}
|
}
|
||||||
@ -715,9 +679,6 @@ private:
|
|||||||
bool fullDash() const { return fFullDash; }
|
bool fullDash() const { return fFullDash; }
|
||||||
SkPaint::Cap cap() const { return fCap; }
|
SkPaint::Cap cap() const { return fCap; }
|
||||||
|
|
||||||
static const int kVertsPerDash = 4;
|
|
||||||
static const int kIndicesPerDash = 6;
|
|
||||||
|
|
||||||
SkSTArray<1, LineData, true> fLines;
|
SkSTArray<1, LineData, true> fLines;
|
||||||
SkPMColor4f fColor;
|
SkPMColor4f fColor;
|
||||||
bool fUsesLocalCoords : 1;
|
bool fUsesLocalCoords : 1;
|
||||||
@ -734,68 +695,6 @@ private:
|
|||||||
using INHERITED = GrMeshDrawOp;
|
using INHERITED = GrMeshDrawOp;
|
||||||
};
|
};
|
||||||
|
|
||||||
GrOp::Owner GrDashOp::MakeDashLineOp(GrRecordingContext* context,
|
|
||||||
GrPaint&& paint,
|
|
||||||
const SkMatrix& viewMatrix,
|
|
||||||
const SkPoint pts[2],
|
|
||||||
AAMode aaMode,
|
|
||||||
const GrStyle& style,
|
|
||||||
const GrUserStencilSettings* stencilSettings) {
|
|
||||||
SkASSERT(GrDashOp::CanDrawDashLine(pts, style, viewMatrix));
|
|
||||||
const SkScalar* intervals = style.dashIntervals();
|
|
||||||
SkScalar phase = style.dashPhase();
|
|
||||||
|
|
||||||
SkPaint::Cap cap = style.strokeRec().getCap();
|
|
||||||
|
|
||||||
DashOp::LineData lineData;
|
|
||||||
lineData.fSrcStrokeWidth = style.strokeRec().getWidth();
|
|
||||||
|
|
||||||
// the phase should be normalized to be [0, sum of all intervals)
|
|
||||||
SkASSERT(phase >= 0 && phase < intervals[0] + intervals[1]);
|
|
||||||
|
|
||||||
// Rotate the src pts so they are aligned horizontally with pts[0].fX < pts[1].fX
|
|
||||||
if (pts[0].fY != pts[1].fY || pts[0].fX > pts[1].fX) {
|
|
||||||
SkMatrix rotMatrix;
|
|
||||||
align_to_x_axis(pts, &rotMatrix, lineData.fPtsRot);
|
|
||||||
if (!rotMatrix.invert(&lineData.fSrcRotInv)) {
|
|
||||||
SkDebugf("Failed to create invertible rotation matrix!\n");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lineData.fSrcRotInv.reset();
|
|
||||||
memcpy(lineData.fPtsRot, pts, 2 * sizeof(SkPoint));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scale corrections of intervals and stroke from view matrix
|
|
||||||
calc_dash_scaling(&lineData.fParallelScale, &lineData.fPerpendicularScale, viewMatrix, pts);
|
|
||||||
if (SkScalarNearlyZero(lineData.fParallelScale) ||
|
|
||||||
SkScalarNearlyZero(lineData.fPerpendicularScale)) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkScalar offInterval = intervals[1] * lineData.fParallelScale;
|
|
||||||
SkScalar strokeWidth = lineData.fSrcStrokeWidth * lineData.fPerpendicularScale;
|
|
||||||
|
|
||||||
if (SkPaint::kSquare_Cap == cap && 0 != lineData.fSrcStrokeWidth) {
|
|
||||||
// add cap to on interval and remove from off interval
|
|
||||||
offInterval -= strokeWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO we can do a real rect call if not using fulldash(ie no off interval, not using AA)
|
|
||||||
bool fullDash = offInterval > 0.f || aaMode != AAMode::kNone;
|
|
||||||
|
|
||||||
lineData.fViewMatrix = viewMatrix;
|
|
||||||
lineData.fPhase = phase;
|
|
||||||
lineData.fIntervals[0] = intervals[0];
|
|
||||||
lineData.fIntervals[1] = intervals[1];
|
|
||||||
|
|
||||||
return DashOp::Make(context, std::move(paint), lineData, cap, aaMode, fullDash,
|
|
||||||
stencilSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
/*
|
/*
|
||||||
* This effect will draw a dotted line (defined as a dashed lined with round caps and no on
|
* This effect will draw a dotted line (defined as a dashed lined with round caps and no on
|
||||||
* interval). The radius of the dots is given by the strokeWidth and the spacing by the DashInfo.
|
* interval). The radius of the dots is given by the strokeWidth and the spacing by the DashInfo.
|
||||||
@ -840,7 +739,6 @@ private:
|
|||||||
|
|
||||||
using INHERITED = GrGeometryProcessor;
|
using INHERITED = GrGeometryProcessor;
|
||||||
};
|
};
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -974,7 +872,7 @@ GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect);
|
|||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
GrGeometryProcessor* DashingCircleEffect::TestCreate(GrProcessorTestData* d) {
|
GrGeometryProcessor* DashingCircleEffect::TestCreate(GrProcessorTestData* d) {
|
||||||
AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashOp::kAAModeCnt));
|
AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(kAAModeCnt));
|
||||||
GrColor color = GrTest::RandomColor(d->fRandom);
|
GrColor color = GrTest::RandomColor(d->fRandom);
|
||||||
SkMatrix matrix = GrTest::TestMatrix(d->fRandom);
|
SkMatrix matrix = GrTest::TestMatrix(d->fRandom);
|
||||||
return DashingCircleEffect::Make(d->allocator(),
|
return DashingCircleEffect::Make(d->allocator(),
|
||||||
@ -987,7 +885,6 @@ GrGeometryProcessor* DashingCircleEffect::TestCreate(GrProcessorTestData* d) {
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace {
|
|
||||||
/*
|
/*
|
||||||
* This effect will draw a dashed line. The width of the dash is given by the strokeWidth and the
|
* This effect will draw a dashed line. The width of the dash is given by the strokeWidth and the
|
||||||
* length and spacing by the DashInfo. Both of the previous two parameters are in device space.
|
* length and spacing by the DashInfo. Both of the previous two parameters are in device space.
|
||||||
@ -1034,7 +931,6 @@ private:
|
|||||||
|
|
||||||
using INHERITED = GrGeometryProcessor;
|
using INHERITED = GrGeometryProcessor;
|
||||||
};
|
};
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -1175,11 +1071,11 @@ DashingLineEffect::DashingLineEffect(const SkPMColor4f& color,
|
|||||||
AAMode aaMode,
|
AAMode aaMode,
|
||||||
const SkMatrix& localMatrix,
|
const SkMatrix& localMatrix,
|
||||||
bool usesLocalCoords)
|
bool usesLocalCoords)
|
||||||
: INHERITED(kDashingLineEffect_ClassID)
|
: INHERITED(kDashingLineEffect_ClassID)
|
||||||
, fColor(color)
|
, fColor(color)
|
||||||
, fLocalMatrix(localMatrix)
|
, fLocalMatrix(localMatrix)
|
||||||
, fUsesLocalCoords(usesLocalCoords)
|
, fUsesLocalCoords(usesLocalCoords)
|
||||||
, fAAMode(aaMode) {
|
, fAAMode(aaMode) {
|
||||||
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
|
||||||
fInDashParams = {"inDashParams", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
|
fInDashParams = {"inDashParams", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
|
||||||
fInRect = {"inRect", kFloat4_GrVertexAttribType, kHalf4_GrSLType};
|
fInRect = {"inRect", kFloat4_GrVertexAttribType, kHalf4_GrSLType};
|
||||||
@ -1190,7 +1086,7 @@ GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect);
|
|||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) {
|
GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) {
|
||||||
AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashOp::kAAModeCnt));
|
AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(kAAModeCnt));
|
||||||
GrColor color = GrTest::RandomColor(d->fRandom);
|
GrColor color = GrTest::RandomColor(d->fRandom);
|
||||||
SkMatrix matrix = GrTest::TestMatrix(d->fRandom);
|
SkMatrix matrix = GrTest::TestMatrix(d->fRandom);
|
||||||
return DashingLineEffect::Make(d->allocator(),
|
return DashingLineEffect::Make(d->allocator(),
|
||||||
@ -1203,12 +1099,12 @@ GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) {
|
|||||||
#endif
|
#endif
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static GrGeometryProcessor* make_dash_gp(SkArenaAlloc* arena,
|
GrGeometryProcessor* make_dash_gp(SkArenaAlloc* arena,
|
||||||
const SkPMColor4f& color,
|
const SkPMColor4f& color,
|
||||||
AAMode aaMode,
|
AAMode aaMode,
|
||||||
DashCap cap,
|
DashCap cap,
|
||||||
const SkMatrix& viewMatrix,
|
const SkMatrix& viewMatrix,
|
||||||
bool usesLocalCoords) {
|
bool usesLocalCoords) {
|
||||||
SkMatrix invert;
|
SkMatrix invert;
|
||||||
if (usesLocalCoords && !viewMatrix.invert(&invert)) {
|
if (usesLocalCoords && !viewMatrix.invert(&invert)) {
|
||||||
SkDebugf("Failed to invert\n");
|
SkDebugf("Failed to invert\n");
|
||||||
@ -1224,15 +1120,19 @@ static GrGeometryProcessor* make_dash_gp(SkArenaAlloc* arena,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
|
|
||||||
GR_DRAW_OP_TEST_DEFINE(DashOp) {
|
#include "src/gpu/GrDrawOpTest.h"
|
||||||
|
|
||||||
|
GR_DRAW_OP_TEST_DEFINE(DashOpImpl) {
|
||||||
SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random);
|
SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random);
|
||||||
AAMode aaMode;
|
AAMode aaMode;
|
||||||
do {
|
do {
|
||||||
aaMode = static_cast<AAMode>(random->nextULessThan(GrDashOp::kAAModeCnt));
|
aaMode = static_cast<AAMode>(random->nextULessThan(kAAModeCnt));
|
||||||
} while (AAMode::kCoverageWithMSAA == aaMode && numSamples <= 1);
|
} while (AAMode::kCoverageWithMSAA == aaMode && numSamples <= 1);
|
||||||
|
|
||||||
// We can only dash either horizontal or vertical lines
|
// We can only dash either horizontal or vertical lines
|
||||||
@ -1298,8 +1198,111 @@ GR_DRAW_OP_TEST_DEFINE(DashOp) {
|
|||||||
|
|
||||||
GrStyle style(p);
|
GrStyle style(p);
|
||||||
|
|
||||||
return GrDashOp::MakeDashLineOp(context, std::move(paint), viewMatrix, pts, aaMode, style,
|
return skgpu::v1::DashOp::MakeDashLineOp(context, std::move(paint), viewMatrix, pts, aaMode,
|
||||||
GrGetRandomStencil(random, context));
|
style, GrGetRandomStencil(random, context));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // GR_TEST_UTILS
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace skgpu::v1::DashOp {
|
||||||
|
|
||||||
|
GrOp::Owner MakeDashLineOp(GrRecordingContext* context,
|
||||||
|
GrPaint&& paint,
|
||||||
|
const SkMatrix& viewMatrix,
|
||||||
|
const SkPoint pts[2],
|
||||||
|
AAMode aaMode,
|
||||||
|
const GrStyle& style,
|
||||||
|
const GrUserStencilSettings* stencilSettings) {
|
||||||
|
SkASSERT(CanDrawDashLine(pts, style, viewMatrix));
|
||||||
|
const SkScalar* intervals = style.dashIntervals();
|
||||||
|
SkScalar phase = style.dashPhase();
|
||||||
|
|
||||||
|
SkPaint::Cap cap = style.strokeRec().getCap();
|
||||||
|
|
||||||
|
DashOpImpl::LineData lineData;
|
||||||
|
lineData.fSrcStrokeWidth = style.strokeRec().getWidth();
|
||||||
|
|
||||||
|
// the phase should be normalized to be [0, sum of all intervals)
|
||||||
|
SkASSERT(phase >= 0 && phase < intervals[0] + intervals[1]);
|
||||||
|
|
||||||
|
// Rotate the src pts so they are aligned horizontally with pts[0].fX < pts[1].fX
|
||||||
|
if (pts[0].fY != pts[1].fY || pts[0].fX > pts[1].fX) {
|
||||||
|
SkMatrix rotMatrix;
|
||||||
|
align_to_x_axis(pts, &rotMatrix, lineData.fPtsRot);
|
||||||
|
if (!rotMatrix.invert(&lineData.fSrcRotInv)) {
|
||||||
|
SkDebugf("Failed to create invertible rotation matrix!\n");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lineData.fSrcRotInv.reset();
|
||||||
|
memcpy(lineData.fPtsRot, pts, 2 * sizeof(SkPoint));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scale corrections of intervals and stroke from view matrix
|
||||||
|
calc_dash_scaling(&lineData.fParallelScale, &lineData.fPerpendicularScale, viewMatrix, pts);
|
||||||
|
if (SkScalarNearlyZero(lineData.fParallelScale) ||
|
||||||
|
SkScalarNearlyZero(lineData.fPerpendicularScale)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkScalar offInterval = intervals[1] * lineData.fParallelScale;
|
||||||
|
SkScalar strokeWidth = lineData.fSrcStrokeWidth * lineData.fPerpendicularScale;
|
||||||
|
|
||||||
|
if (SkPaint::kSquare_Cap == cap && 0 != lineData.fSrcStrokeWidth) {
|
||||||
|
// add cap to on interval and remove from off interval
|
||||||
|
offInterval -= strokeWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO we can do a real rect call if not using fulldash(ie no off interval, not using AA)
|
||||||
|
bool fullDash = offInterval > 0.f || aaMode != AAMode::kNone;
|
||||||
|
|
||||||
|
lineData.fViewMatrix = viewMatrix;
|
||||||
|
lineData.fPhase = phase;
|
||||||
|
lineData.fIntervals[0] = intervals[0];
|
||||||
|
lineData.fIntervals[1] = intervals[1];
|
||||||
|
|
||||||
|
return DashOpImpl::Make(context, std::move(paint), lineData, cap, aaMode, fullDash,
|
||||||
|
stencilSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns whether or not the gpu can fast path the dash line effect.
|
||||||
|
bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style, const SkMatrix& viewMatrix) {
|
||||||
|
// Pts must be either horizontal or vertical in src space
|
||||||
|
if (pts[0].fX != pts[1].fX && pts[0].fY != pts[1].fY) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// May be able to relax this to include skew. As of now cannot do perspective
|
||||||
|
// because of the non uniform scaling of bloating a rect
|
||||||
|
if (!viewMatrix.preservesRightAngles()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!style.isDashed() || 2 != style.dashIntervalCnt()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SkScalar* intervals = style.dashIntervals();
|
||||||
|
if (0 == intervals[0] && 0 == intervals[1]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkPaint::Cap cap = style.strokeRec().getCap();
|
||||||
|
if (SkPaint::kRound_Cap == cap) {
|
||||||
|
// Current we don't support round caps unless the on interval is zero
|
||||||
|
if (intervals[0] != 0.f) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// If the width of the circle caps in greater than the off interval we will pick up unwanted
|
||||||
|
// segments of circles at the start and end of the dash line.
|
||||||
|
if (style.strokeRec().getWidth() > intervals[1]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace skgpu::v1::DashOp
|
@ -5,26 +5,24 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GrDashOp_DEFINED
|
#ifndef DashOp_DEFINED
|
||||||
#define GrDashOp_DEFINED
|
#define DashOp_DEFINED
|
||||||
|
|
||||||
#include "include/core/SkPathEffect.h"
|
|
||||||
#include "include/gpu/GrTypes.h"
|
#include "include/gpu/GrTypes.h"
|
||||||
#include "src/gpu/ops/GrOp.h"
|
#include "src/gpu/ops/GrOp.h"
|
||||||
|
|
||||||
class GrDrawOp;
|
|
||||||
class GrPaint;
|
class GrPaint;
|
||||||
class GrRecordingContext;
|
class GrRecordingContext;
|
||||||
class GrStyle;
|
class GrStyle;
|
||||||
struct GrUserStencilSettings;
|
struct GrUserStencilSettings;
|
||||||
|
|
||||||
namespace GrDashOp {
|
namespace skgpu::v1::DashOp {
|
||||||
|
|
||||||
enum class AAMode {
|
enum class AAMode {
|
||||||
kNone,
|
kNone,
|
||||||
kCoverage,
|
kCoverage,
|
||||||
kCoverageWithMSAA,
|
kCoverageWithMSAA,
|
||||||
};
|
};
|
||||||
static const int kAAModeCnt = static_cast<int>(AAMode::kCoverageWithMSAA) + 1;
|
|
||||||
|
|
||||||
GrOp::Owner MakeDashLineOp(GrRecordingContext*,
|
GrOp::Owner MakeDashLineOp(GrRecordingContext*,
|
||||||
GrPaint&&,
|
GrPaint&&,
|
||||||
@ -34,6 +32,7 @@ GrOp::Owner MakeDashLineOp(GrRecordingContext*,
|
|||||||
const GrStyle& style,
|
const GrStyle& style,
|
||||||
const GrUserStencilSettings*);
|
const GrUserStencilSettings*);
|
||||||
bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style, const SkMatrix& viewMatrix);
|
bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style, const SkMatrix& viewMatrix);
|
||||||
} // namespace GrDashOp
|
|
||||||
|
|
||||||
#endif
|
} // namespace skgpu::v1::DashOp
|
||||||
|
|
||||||
|
#endif // DashOp_DEFINED
|
@ -24,7 +24,6 @@
|
|||||||
#include "src/gpu/GrResourceProvider.h"
|
#include "src/gpu/GrResourceProvider.h"
|
||||||
#include "src/gpu/GrTexture.h"
|
#include "src/gpu/GrTexture.h"
|
||||||
#include "src/gpu/geometry/GrRect.h"
|
#include "src/gpu/geometry/GrRect.h"
|
||||||
#include "src/gpu/ops/GrClearOp.h"
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -53,10 +53,10 @@
|
|||||||
#include "src/gpu/geometry/GrQuad.h"
|
#include "src/gpu/geometry/GrQuad.h"
|
||||||
#include "src/gpu/geometry/GrQuadUtils.h"
|
#include "src/gpu/geometry/GrQuadUtils.h"
|
||||||
#include "src/gpu/geometry/GrStyledShape.h"
|
#include "src/gpu/geometry/GrStyledShape.h"
|
||||||
|
#include "src/gpu/ops/ClearOp.h"
|
||||||
#include "src/gpu/ops/DrawAtlasOp.h"
|
#include "src/gpu/ops/DrawAtlasOp.h"
|
||||||
#include "src/gpu/ops/DrawVerticesOp.h"
|
#include "src/gpu/ops/DrawVerticesOp.h"
|
||||||
#include "src/gpu/ops/DrawableOp.h"
|
#include "src/gpu/ops/DrawableOp.h"
|
||||||
#include "src/gpu/ops/GrClearOp.h"
|
|
||||||
#include "src/gpu/ops/GrDrawOp.h"
|
#include "src/gpu/ops/GrDrawOp.h"
|
||||||
#include "src/gpu/ops/GrFillRRectOp.h"
|
#include "src/gpu/ops/GrFillRRectOp.h"
|
||||||
#include "src/gpu/ops/GrFillRectOp.h"
|
#include "src/gpu/ops/GrFillRectOp.h"
|
||||||
@ -905,7 +905,7 @@ void SurfaceDrawContext::internalStencilClear(const SkIRect* scissor, bool insid
|
|||||||
GrFillRectOp::MakeNonAARect(fContext, std::move(paint), SkMatrix::I(),
|
GrFillRectOp::MakeNonAARect(fContext, std::move(paint), SkMatrix::I(),
|
||||||
SkRect::Make(scissorState.rect()), ss));
|
SkRect::Make(scissorState.rect()), ss));
|
||||||
} else {
|
} else {
|
||||||
this->addOp(GrClearOp::MakeStencilClip(fContext, scissorState, insideStencilMask));
|
this->addOp(ClearOp::MakeStencilClip(fContext, scissorState, insideStencilMask));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "src/gpu/GrProxyProvider.h"
|
#include "src/gpu/GrProxyProvider.h"
|
||||||
#include "src/gpu/effects/GrTextureEffect.h"
|
#include "src/gpu/effects/GrTextureEffect.h"
|
||||||
#include "src/gpu/geometry/GrRect.h"
|
#include "src/gpu/geometry/GrRect.h"
|
||||||
#include "src/gpu/ops/GrClearOp.h"
|
#include "src/gpu/ops/ClearOp.h"
|
||||||
#include "src/gpu/ops/GrFillRectOp.h"
|
#include "src/gpu/ops/GrFillRectOp.h"
|
||||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ void SurfaceFillContext::internalClear(const SkIRect* scissor,
|
|||||||
this->addDrawOp(std::move(op));
|
this->addDrawOp(std::move(op));
|
||||||
} else {
|
} else {
|
||||||
color = this->writeSurfaceView().swizzle().applyTo(color);
|
color = this->writeSurfaceView().swizzle().applyTo(color);
|
||||||
this->addOp(GrClearOp::MakeColor(fContext, scissorState, color));
|
this->addOp(ClearOp::MakeColor(fContext, scissorState, color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "src/gpu/GrColor.h"
|
#include "src/gpu/GrColor.h"
|
||||||
#include "src/gpu/GrDirectContextPriv.h"
|
#include "src/gpu/GrDirectContextPriv.h"
|
||||||
#include "src/gpu/GrImageInfo.h"
|
#include "src/gpu/GrImageInfo.h"
|
||||||
#include "src/gpu/ops/GrClearOp.h"
|
#include "src/gpu/ops/ClearOp.h"
|
||||||
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
#include "src/gpu/v1/SurfaceDrawContext_v1.h"
|
||||||
#include "tests/Test.h"
|
#include "tests/Test.h"
|
||||||
#include "tools/gpu/GrContextFactory.h"
|
#include "tools/gpu/GrContextFactory.h"
|
||||||
@ -31,8 +31,11 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
using SurfaceDrawContext = skgpu::v1::SurfaceDrawContext;
|
||||||
|
using ClearOp = skgpu::v1::ClearOp;
|
||||||
|
|
||||||
static bool check_rect(GrDirectContext* dContext,
|
static bool check_rect(GrDirectContext* dContext,
|
||||||
skgpu::v1::SurfaceDrawContext* sdc,
|
SurfaceDrawContext* sdc,
|
||||||
const SkIRect& rect,
|
const SkIRect& rect,
|
||||||
uint32_t expectedValue,
|
uint32_t expectedValue,
|
||||||
uint32_t* actualValue,
|
uint32_t* actualValue,
|
||||||
@ -65,10 +68,9 @@ static bool check_rect(GrDirectContext* dContext,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<skgpu::v1::SurfaceDrawContext> newSDC(GrRecordingContext* rContext, int w, int h) {
|
std::unique_ptr<SurfaceDrawContext> newSDC(GrRecordingContext* rContext, int w, int h) {
|
||||||
return skgpu::v1::SurfaceDrawContext::Make(
|
return SurfaceDrawContext::Make(rContext, GrColorType::kRGBA_8888, nullptr,
|
||||||
rContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {w, h},
|
SkBackingFit::kExact, {w, h}, SkSurfaceProps());
|
||||||
SkSurfaceProps());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clear_op_test(skiatest::Reporter* reporter, GrDirectContext* dContext) {
|
static void clear_op_test(skiatest::Reporter* reporter, GrDirectContext* dContext) {
|
||||||
@ -76,7 +78,7 @@ static void clear_op_test(skiatest::Reporter* reporter, GrDirectContext* dContex
|
|||||||
static const int kH = 10;
|
static const int kH = 10;
|
||||||
|
|
||||||
SkIRect fullRect = SkIRect::MakeWH(kW, kH);
|
SkIRect fullRect = SkIRect::MakeWH(kW, kH);
|
||||||
std::unique_ptr<skgpu::v1::SurfaceDrawContext> sdc;
|
std::unique_ptr<SurfaceDrawContext> sdc;
|
||||||
|
|
||||||
// A rectangle that is inset by one on all sides and the 1-pixel wide rectangles that surround
|
// A rectangle that is inset by one on all sides and the 1-pixel wide rectangles that surround
|
||||||
// it.
|
// it.
|
||||||
@ -253,7 +255,7 @@ static void clear_op_test(skiatest::Reporter* reporter, GrDirectContext* dContex
|
|||||||
auto opsTask = sdc->getOpsTask();
|
auto opsTask = sdc->getOpsTask();
|
||||||
REPORTER_ASSERT(reporter, opsTask->numOpChains() == 1);
|
REPORTER_ASSERT(reporter, opsTask->numOpChains() == 1);
|
||||||
|
|
||||||
const GrClearOp& clearOp = opsTask->getChain(0)->cast<GrClearOp>();
|
const ClearOp& clearOp = opsTask->getChain(0)->cast<ClearOp>();
|
||||||
|
|
||||||
constexpr std::array<float, 4> kExpected { 0, 0, 0, 1 };
|
constexpr std::array<float, 4> kExpected { 0, 0, 0, 1 };
|
||||||
REPORTER_ASSERT(reporter, clearOp.color() == kExpected);
|
REPORTER_ASSERT(reporter, clearOp.color() == kExpected);
|
||||||
@ -279,7 +281,7 @@ static void clear_op_test(skiatest::Reporter* reporter, GrDirectContext* dContex
|
|||||||
auto opsTask = sdc->getOpsTask();
|
auto opsTask = sdc->getOpsTask();
|
||||||
REPORTER_ASSERT(reporter, opsTask->numOpChains() == 1);
|
REPORTER_ASSERT(reporter, opsTask->numOpChains() == 1);
|
||||||
|
|
||||||
const GrClearOp& clearOp = opsTask->getChain(0)->cast<GrClearOp>();
|
const ClearOp& clearOp = opsTask->getChain(0)->cast<ClearOp>();
|
||||||
|
|
||||||
constexpr std::array<float, 4> kExpected { 1, 1, 1, 1 };
|
constexpr std::array<float, 4> kExpected { 1, 1, 1, 1 };
|
||||||
REPORTER_ASSERT(reporter, clearOp.color() == kExpected);
|
REPORTER_ASSERT(reporter, clearOp.color() == kExpected);
|
||||||
|
@ -48,7 +48,7 @@ DRAW_OP_TEST_EXTERN(AAStrokeRectOp);
|
|||||||
DRAW_OP_TEST_EXTERN(AtlasTextOp);
|
DRAW_OP_TEST_EXTERN(AtlasTextOp);
|
||||||
DRAW_OP_TEST_EXTERN(ButtCapDashedCircleOp);
|
DRAW_OP_TEST_EXTERN(ButtCapDashedCircleOp);
|
||||||
DRAW_OP_TEST_EXTERN(CircleOp);
|
DRAW_OP_TEST_EXTERN(CircleOp);
|
||||||
DRAW_OP_TEST_EXTERN(DashOp);
|
DRAW_OP_TEST_EXTERN(DashOpImpl);
|
||||||
DRAW_OP_TEST_EXTERN(DefaultPathOp);
|
DRAW_OP_TEST_EXTERN(DefaultPathOp);
|
||||||
DRAW_OP_TEST_EXTERN(DrawAtlasOp);
|
DRAW_OP_TEST_EXTERN(DrawAtlasOp);
|
||||||
DRAW_OP_TEST_EXTERN(DrawVerticesOp);
|
DRAW_OP_TEST_EXTERN(DrawVerticesOp);
|
||||||
@ -79,7 +79,7 @@ void GrDrawRandomOp(SkRandom* random, skgpu::v1::SurfaceDrawContext* sdc, GrPain
|
|||||||
DRAW_OP_TEST_ENTRY(AtlasTextOp),
|
DRAW_OP_TEST_ENTRY(AtlasTextOp),
|
||||||
DRAW_OP_TEST_ENTRY(ButtCapDashedCircleOp),
|
DRAW_OP_TEST_ENTRY(ButtCapDashedCircleOp),
|
||||||
DRAW_OP_TEST_ENTRY(CircleOp),
|
DRAW_OP_TEST_ENTRY(CircleOp),
|
||||||
DRAW_OP_TEST_ENTRY(DashOp),
|
DRAW_OP_TEST_ENTRY(DashOpImpl),
|
||||||
DRAW_OP_TEST_ENTRY(DefaultPathOp),
|
DRAW_OP_TEST_ENTRY(DefaultPathOp),
|
||||||
DRAW_OP_TEST_ENTRY(DrawAtlasOp),
|
DRAW_OP_TEST_ENTRY(DrawAtlasOp),
|
||||||
DRAW_OP_TEST_ENTRY(DrawVerticesOp),
|
DRAW_OP_TEST_ENTRY(DrawVerticesOp),
|
||||||
|
Loading…
Reference in New Issue
Block a user