Remove secret wireframe mode from drawVertices

Now, drawing vertices without colors or a shader simply fills with the
paint color, like anyone would expect.

Bug: skia:9984
Change-Id: I9f7cf72f89948756b9c2c6e055a11c6b64fc22ff
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282043
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2020-04-07 13:48:15 -04:00 committed by Skia Commit-Bot
parent 9e1c691c94
commit 62a0fb2837
4 changed files with 9 additions and 117 deletions

View File

@ -8,6 +8,10 @@ Milestone 84
* <insert new release note here>
* SkCanvas::drawVertices will now always fill the triangles specified by the vertices. Previously,
vertices with no colors and no (texture coordinates or shader) would be drawn in wireframe.
https://review.skia.org/282043
* * *
Milestone 83

View File

@ -109,10 +109,6 @@ private:
}
};
static SkScan::HairRCProc ChooseHairProc(bool doAntiAlias) {
return doAntiAlias ? SkScan::AntiHairLine : SkScan::HairLine;
}
static bool SK_WARN_UNUSED_RESULT
texture_to_matrix(const VertState& state, const SkPoint verts[], const SkPoint texs[],
SkMatrix* matrix) {
@ -311,43 +307,6 @@ void SkDraw::draw_fixed_vertices(const SkVertices* vertices, SkBlendMode bmode,
VertState state(vertexCount, indices, indexCount);
VertState::Proc vertProc = state.chooseProc(info.mode());
// Draw hairlines to show the skeleton
if (!(colors || textures)) {
// no colors[] and no texture, stroke hairlines with paint's color.
SkPaint p;
p.setStyle(SkPaint::kStroke_Style);
SkAutoBlitterChoose blitter(*this, nullptr, p);
// Abort early if we failed to create a shader context.
if (blitter->isNullBlitter()) {
return;
}
SkScan::HairRCProc hairProc = ChooseHairProc(paint.isAntiAlias());
const SkRasterClip& clip = *fRC;
while (vertProc(&state)) {
if (dev3) {
SkPoint tmp[kMaxClippedTrianglePointCount + 2];
int idx[] = { state.f0, state.f1, state.f2 };
if (int n = clip_triangle(tmp, idx, dev3)) {
tmp[n] = tmp[0]; // close the poly
if (n == 3) {
n = 4;
} else {
SkASSERT(n == 4);
tmp[5] = tmp[2]; // add diagonal
n = 6;
}
hairProc(tmp, n, clip, blitter.get());
}
} else {
SkPoint array[] = {
dev2[state.f0], dev2[state.f1], dev2[state.f2], dev2[state.f0]
};
hairProc(array, 4, clip, blitter.get());
}
}
return;
}
SkTriColorShader* triShader = nullptr;
SkPMColor4f* dstColors = nullptr;
@ -370,9 +329,11 @@ void SkDraw::draw_fixed_vertices(const SkVertices* vertices, SkBlendMode bmode,
auto blitter = SkCreateRasterPipelineBlitter(fDst, p, *fMatrix, outerAlloc,
this->fRC->clipShader());
while (vertProc(&state)) {
if (triShader->update(ctmInv, positions, dstColors, state.f0, state.f1, state.f2)) {
fill_triangle(state, blitter, *fRC, dev2, dev3);
if (triShader &&
!triShader->update(ctmInv, positions, dstColors, state.f0, state.f1, state.f2)) {
continue;
}
fill_triangle(state, blitter, *fRC, dev2, dev3);
}
return;
}

View File

@ -29,7 +29,6 @@
#include "src/core/SkSpecialImage.h"
#include "src/core/SkStroke.h"
#include "src/core/SkTLazy.h"
#include "src/core/SkVertState.h"
#include "src/core/SkVerticesPriv.h"
#include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrBlurUtils.h"
@ -963,69 +962,6 @@ static bool init_vertices_paint(GrContext* context, const GrColorInfo& colorInfo
}
}
void SkGpuDevice::wireframeVertices(SkVertices::VertexMode vmode, int vertexCount,
const SkPoint vertices[],
SkBlendMode bmode,
const uint16_t indices[], int indexCount,
const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "wireframeVertices", fContext.get());
SkPaint copy(paint);
copy.setStyle(SkPaint::kStroke_Style);
copy.setStrokeWidth(0);
GrPaint grPaint;
// we ignore the shader since we have no texture coordinates.
if (!SkPaintToGrPaintNoShader(this->context(), fRenderTargetContext->colorInfo(), copy,
&grPaint)) {
return;
}
int triangleCount = 0;
int n = (nullptr == indices) ? vertexCount : indexCount;
switch (vmode) {
case SkVertices::kTriangles_VertexMode:
triangleCount = n / 3;
break;
case SkVertices::kTriangleStrip_VertexMode:
triangleCount = n - 2;
break;
case SkVertices::kTriangleFan_VertexMode:
SK_ABORT("Unexpected triangle fan.");
break;
}
VertState state(vertexCount, indices, indexCount);
VertState::Proc vertProc = state.chooseProc(vmode);
//number of indices for lines per triangle with kLines
indexCount = triangleCount * 6;
static constexpr SkVertices::VertexMode kIgnoredMode = SkVertices::kTriangles_VertexMode;
SkVertices::Builder builder(kIgnoredMode, vertexCount, indexCount, 0);
memcpy(builder.positions(), vertices, vertexCount * sizeof(SkPoint));
uint16_t* lineIndices = builder.indices();
int i = 0;
while (vertProc(&state)) {
lineIndices[i] = state.f0;
lineIndices[i + 1] = state.f1;
lineIndices[i + 2] = state.f1;
lineIndices[i + 3] = state.f2;
lineIndices[i + 4] = state.f2;
lineIndices[i + 5] = state.f0;
i += 6;
}
GrPrimitiveType primitiveType = GrPrimitiveType::kLines;
fRenderTargetContext->drawVertices(this->clip(),
std::move(grPaint),
this->localToDevice(),
builder.detach(),
&primitiveType);
}
void SkGpuDevice::drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawVertices", fContext.get());
@ -1041,12 +977,6 @@ void SkGpuDevice::drawVertices(const SkVertices* vertices, SkBlendMode mode, con
GrPaint grPaint;
bool hasColors = info.hasColors();
bool hasTexs = info.hasTexCoords() || info.hasCustomData();
if ((!hasTexs || !paint.getShader()) && !hasColors) {
// The dreaded wireframe mode. Fallback to drawVertices and go so slooooooow.
this->wireframeVertices(info.mode(), info.vertexCount(), info.positions(), mode,
info.indices(), info.indexCount(), paint);
return;
}
if (!init_vertices_paint(fContext.get(), fRenderTargetContext->colorInfo(), paint,
this->localToDevice(), mode, hasTexs, hasColors, &grPaint)) {
return;

View File

@ -12,7 +12,6 @@
#include "include/core/SkPicture.h"
#include "include/core/SkRegion.h"
#include "include/core/SkSurface.h"
#include "include/core/SkVertices.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/GrTypes.h"
#include "src/core/SkClipStackDevice.h"
@ -28,6 +27,7 @@ struct GrCachedLayer;
class SkSpecialImage;
class SkSurface;
class SkVertices;
/**
* Subclass of SkBaseDevice, which directs all drawing to the GrGpu owned by the
@ -168,9 +168,6 @@ private:
void drawStrokedLine(const SkPoint pts[2], const SkPaint&);
void wireframeVertices(SkVertices::VertexMode, int vertexCount, const SkPoint verts[],
SkBlendMode, const uint16_t indices[], int indexCount, const SkPaint&);
static std::unique_ptr<GrRenderTargetContext> MakeRenderTargetContext(GrContext*,
SkBudgeted,
const SkImageInfo&,