Store clipped bounds on GrOp rather than in parallel in GrRenderTargetOpList.
When the op is recorded we update its bounds to incorporate both clipping and aa bloat. Change-Id: Ia205e058ebeda5fcdb2cd5e9b8a30a4972672b14 Reviewed-on: https://skia-review.googlesource.com/9233 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
488f0d6748
commit
9e50f7b11e
@ -34,16 +34,16 @@ public:
|
|||||||
|
|
||||||
const char* name() const override { return "BezierCubicOrConicTestOp"; }
|
const char* name() const override { return "BezierCubicOrConicTestOp"; }
|
||||||
|
|
||||||
static std::unique_ptr<GrDrawOp> Make(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds,
|
static std::unique_ptr<GrDrawOp> Make(sk_sp<GrGeometryProcessor> gp, const SkRect& rect,
|
||||||
GrColor color, const SkScalar klmEqs[9], SkScalar sign) {
|
GrColor color, const SkScalar klmEqs[9], SkScalar sign) {
|
||||||
return std::unique_ptr<GrDrawOp>(
|
return std::unique_ptr<GrDrawOp>(
|
||||||
new BezierCubicOrConicTestOp(gp, bounds, color, klmEqs, sign));
|
new BezierCubicOrConicTestOp(gp, rect, color, klmEqs, sign));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BezierCubicOrConicTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds, GrColor color,
|
BezierCubicOrConicTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
|
||||||
const SkScalar klmEqs[9], SkScalar sign)
|
const SkScalar klmEqs[9], SkScalar sign)
|
||||||
: INHERITED(ClassID(), bounds, color), fGeometryProcessor(std::move(gp)) {
|
: INHERITED(ClassID(), rect, color), fRect(rect), fGeometryProcessor(std::move(gp)) {
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
fKlmEqs[i] = klmEqs[i];
|
fKlmEqs[i] = klmEqs[i];
|
||||||
}
|
}
|
||||||
@ -62,8 +62,7 @@ private:
|
|||||||
if (!verts) {
|
if (!verts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const SkRect& bounds = this->bounds();
|
verts[0].fPosition.setRectFan(fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom,
|
||||||
verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom,
|
|
||||||
sizeof(Vertex));
|
sizeof(Vertex));
|
||||||
for (int v = 0; v < 4; ++v) {
|
for (int v = 0; v < 4; ++v) {
|
||||||
verts[v].fKLM[0] = eval_line(verts[v].fPosition, fKlmEqs + 0, fSign);
|
verts[v].fKLM[0] = eval_line(verts[v].fPosition, fKlmEqs + 0, fSign);
|
||||||
@ -75,6 +74,7 @@ private:
|
|||||||
|
|
||||||
SkScalar fKlmEqs[9];
|
SkScalar fKlmEqs[9];
|
||||||
SkScalar fSign;
|
SkScalar fSign;
|
||||||
|
SkRect fRect;
|
||||||
sk_sp<GrGeometryProcessor> fGeometryProcessor;
|
sk_sp<GrGeometryProcessor> fGeometryProcessor;
|
||||||
|
|
||||||
static constexpr int kVertsPerCubic = 4;
|
static constexpr int kVertsPerCubic = 4;
|
||||||
@ -394,16 +394,17 @@ public:
|
|||||||
DEFINE_OP_CLASS_ID
|
DEFINE_OP_CLASS_ID
|
||||||
const char* name() const override { return "BezierQuadTestOp"; }
|
const char* name() const override { return "BezierQuadTestOp"; }
|
||||||
|
|
||||||
static std::unique_ptr<GrDrawOp> Make(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds,
|
static std::unique_ptr<GrDrawOp> Make(sk_sp<GrGeometryProcessor> gp, const SkRect& rect,
|
||||||
GrColor color, const GrPathUtils::QuadUVMatrix& devToUV) {
|
GrColor color, const GrPathUtils::QuadUVMatrix& devToUV) {
|
||||||
return std::unique_ptr<GrDrawOp>(new BezierQuadTestOp(gp, bounds, color, devToUV));
|
return std::unique_ptr<GrDrawOp>(new BezierQuadTestOp(gp, rect, color, devToUV));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BezierQuadTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds, GrColor color,
|
BezierQuadTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
|
||||||
const GrPathUtils::QuadUVMatrix& devToUV)
|
const GrPathUtils::QuadUVMatrix& devToUV)
|
||||||
: INHERITED(ClassID(), bounds, color)
|
: INHERITED(ClassID(), rect, color)
|
||||||
, fDevToUV(devToUV)
|
, fDevToUV(devToUV)
|
||||||
|
, fRect(rect)
|
||||||
, fGeometryProcessor(std::move(gp)) {}
|
, fGeometryProcessor(std::move(gp)) {}
|
||||||
|
|
||||||
struct Vertex {
|
struct Vertex {
|
||||||
@ -419,14 +420,14 @@ private:
|
|||||||
if (!verts) {
|
if (!verts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const SkRect& bounds = this->bounds();
|
verts[0].fPosition.setRectFan(fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom,
|
||||||
verts[0].fPosition.setRectFan(bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom,
|
|
||||||
sizeof(Vertex));
|
sizeof(Vertex));
|
||||||
fDevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts);
|
fDevToUV.apply<4, sizeof(Vertex), sizeof(SkPoint)>(verts);
|
||||||
helper.recordDraw(target, fGeometryProcessor.get());
|
helper.recordDraw(target, fGeometryProcessor.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
GrPathUtils::QuadUVMatrix fDevToUV;
|
GrPathUtils::QuadUVMatrix fDevToUV;
|
||||||
|
SkRect fRect;
|
||||||
sk_sp<GrGeometryProcessor> fGeometryProcessor;
|
sk_sp<GrGeometryProcessor> fGeometryProcessor;
|
||||||
|
|
||||||
static constexpr int kVertsPerCubic = 4;
|
static constexpr int kVertsPerCubic = 4;
|
||||||
|
@ -84,10 +84,9 @@ void GrRenderTargetOpList::dump() const {
|
|||||||
SkDebugf("%d: %s\n", i, fRecordedOps[i].fOp->name());
|
SkDebugf("%d: %s\n", i, fRecordedOps[i].fOp->name());
|
||||||
SkString str = fRecordedOps[i].fOp->dumpInfo();
|
SkString str = fRecordedOps[i].fOp->dumpInfo();
|
||||||
SkDebugf("%s\n", str.c_str());
|
SkDebugf("%s\n", str.c_str());
|
||||||
const SkRect& clippedBounds = fRecordedOps[i].fClippedBounds;
|
const SkRect& bounds = fRecordedOps[i].fOp->bounds();
|
||||||
SkDebugf("ClippedBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
|
SkDebugf("ClippedBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", bounds.fLeft,
|
||||||
clippedBounds.fLeft, clippedBounds.fTop, clippedBounds.fRight,
|
bounds.fTop, bounds.fRight, bounds.fBottom);
|
||||||
clippedBounds.fBottom);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,9 +96,6 @@ void GrRenderTargetOpList::setupDstTexture(GrRenderTarget* rt,
|
|||||||
const GrClip& clip,
|
const GrClip& clip,
|
||||||
const SkRect& opBounds,
|
const SkRect& opBounds,
|
||||||
GrXferProcessor::DstTexture* dstTexture) {
|
GrXferProcessor::DstTexture* dstTexture) {
|
||||||
SkRect bounds = opBounds;
|
|
||||||
bounds.outset(0.5f, 0.5f);
|
|
||||||
|
|
||||||
if (this->caps()->textureBarrierSupport()) {
|
if (this->caps()->textureBarrierSupport()) {
|
||||||
if (GrTexture* rtTex = rt->asTexture()) {
|
if (GrTexture* rtTex = rt->asTexture()) {
|
||||||
// The render target is a texture, so we can read from it directly in the shader. The XP
|
// The render target is a texture, so we can read from it directly in the shader. The XP
|
||||||
@ -114,7 +110,7 @@ void GrRenderTargetOpList::setupDstTexture(GrRenderTarget* rt,
|
|||||||
clip.getConservativeBounds(rt->width(), rt->height(), ©Rect);
|
clip.getConservativeBounds(rt->width(), rt->height(), ©Rect);
|
||||||
|
|
||||||
SkIRect drawIBounds;
|
SkIRect drawIBounds;
|
||||||
bounds.roundOut(&drawIBounds);
|
opBounds.roundOut(&drawIBounds);
|
||||||
if (!copyRect.intersect(drawIBounds)) {
|
if (!copyRect.intersect(drawIBounds)) {
|
||||||
#ifdef SK_DEBUG
|
#ifdef SK_DEBUG
|
||||||
GrCapsDebugf(this->caps(), "Missed an early reject. "
|
GrCapsDebugf(this->caps(), "Missed an early reject. "
|
||||||
@ -198,7 +194,7 @@ bool GrRenderTargetOpList::executeOps(GrOpFlushState* flushState) {
|
|||||||
}
|
}
|
||||||
flushState->setCommandBuffer(commandBuffer.get());
|
flushState->setCommandBuffer(commandBuffer.get());
|
||||||
}
|
}
|
||||||
fRecordedOps[i].fOp->execute(flushState, fRecordedOps[i].fClippedBounds);
|
fRecordedOps[i].fOp->execute(flushState);
|
||||||
}
|
}
|
||||||
if (commandBuffer) {
|
if (commandBuffer) {
|
||||||
commandBuffer->end();
|
commandBuffer->end();
|
||||||
@ -304,7 +300,7 @@ void GrRenderTargetOpList::addDrawOp(const GrPipelineBuilder& pipelineBuilder,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pipelineBuilder.willXPNeedDstTexture(*this->caps(), analysis)) {
|
if (pipelineBuilder.willXPNeedDstTexture(*this->caps(), analysis)) {
|
||||||
this->setupDstTexture(renderTargetContext->accessRenderTarget(), clip, op->bounds(),
|
this->setupDstTexture(renderTargetContext->accessRenderTarget(), clip, bounds,
|
||||||
&args.fDstTexture);
|
&args.fDstTexture);
|
||||||
if (!args.fDstTexture.texture()) {
|
if (!args.fDstTexture.texture()) {
|
||||||
return;
|
return;
|
||||||
@ -316,7 +312,8 @@ void GrRenderTargetOpList::addDrawOp(const GrPipelineBuilder& pipelineBuilder,
|
|||||||
SkASSERT(fSurface);
|
SkASSERT(fSurface);
|
||||||
op->pipeline()->addDependenciesTo(fSurface);
|
op->pipeline()->addDependenciesTo(fSurface);
|
||||||
#endif
|
#endif
|
||||||
this->recordOp(std::move(op), renderTargetContext, appliedClip.clippedDrawBounds());
|
op->setClippedBounds(appliedClip.clippedDrawBounds());
|
||||||
|
this->recordOp(std::move(op), renderTargetContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrRenderTargetOpList::stencilPath(GrRenderTargetContext* renderTargetContext,
|
void GrRenderTargetOpList::stencilPath(GrRenderTargetContext* renderTargetContext,
|
||||||
@ -361,7 +358,8 @@ void GrRenderTargetOpList::stencilPath(GrRenderTargetContext* renderTargetContex
|
|||||||
appliedClip.scissorState(),
|
appliedClip.scissorState(),
|
||||||
renderTargetContext->accessRenderTarget(),
|
renderTargetContext->accessRenderTarget(),
|
||||||
path);
|
path);
|
||||||
this->recordOp(std::move(op), renderTargetContext, appliedClip.clippedDrawBounds());
|
op->setClippedBounds(appliedClip.clippedDrawBounds());
|
||||||
|
this->recordOp(std::move(op), renderTargetContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrRenderTargetOpList::fullClear(GrRenderTargetContext* renderTargetContext, GrColor color) {
|
void GrRenderTargetOpList::fullClear(GrRenderTargetContext* renderTargetContext, GrColor color) {
|
||||||
@ -420,18 +418,8 @@ static inline bool can_reorder(const SkRect& a, const SkRect& b) {
|
|||||||
b.fRight <= a.fLeft || b.fBottom <= a.fTop;
|
b.fRight <= a.fLeft || b.fBottom <= a.fTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void join(SkRect* out, const SkRect& a, const SkRect& b) {
|
|
||||||
SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom);
|
|
||||||
SkASSERT(b.fLeft <= b.fRight && b.fTop <= b.fBottom);
|
|
||||||
out->fLeft = SkTMin(a.fLeft, b.fLeft);
|
|
||||||
out->fTop = SkTMin(a.fTop, b.fTop);
|
|
||||||
out->fRight = SkTMax(a.fRight, b.fRight);
|
|
||||||
out->fBottom = SkTMax(a.fBottom, b.fBottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
|
GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
|
||||||
GrRenderTargetContext* renderTargetContext,
|
GrRenderTargetContext* renderTargetContext) {
|
||||||
const SkRect& clippedBounds) {
|
|
||||||
GrRenderTarget* renderTarget =
|
GrRenderTarget* renderTarget =
|
||||||
renderTargetContext ? renderTargetContext->accessRenderTarget()
|
renderTargetContext ? renderTargetContext->accessRenderTarget()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
@ -451,9 +439,8 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
|
|||||||
op->bounds().fLeft, op->bounds().fRight,
|
op->bounds().fLeft, op->bounds().fRight,
|
||||||
op->bounds().fTop, op->bounds().fBottom);
|
op->bounds().fTop, op->bounds().fBottom);
|
||||||
GrOP_INFO(SkTabString(op->dumpInfo(), 1).c_str());
|
GrOP_INFO(SkTabString(op->dumpInfo(), 1).c_str());
|
||||||
GrOP_INFO("\tClipped Bounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
|
GrOP_INFO("\tClipped Bounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", op->bounds().fLeft,
|
||||||
clippedBounds.fLeft, clippedBounds.fTop, clippedBounds.fRight,
|
op->bounds().fTop, op->bounds().fRight, op->bounds().fBottom);
|
||||||
clippedBounds.fBottom);
|
|
||||||
GrOP_INFO("\tOutcome:\n");
|
GrOP_INFO("\tOutcome:\n");
|
||||||
int maxCandidates = SkTMin(fMaxOpLookback, fRecordedOps.count());
|
int maxCandidates = SkTMin(fMaxOpLookback, fRecordedOps.count());
|
||||||
// If we don't have a valid destination render target then we cannot reorder.
|
// If we don't have a valid destination render target then we cannot reorder.
|
||||||
@ -473,13 +460,10 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
|
|||||||
GrOP_INFO("\t\t\tCombined op info:\n");
|
GrOP_INFO("\t\t\tCombined op info:\n");
|
||||||
GrOP_INFO(SkTabString(candidate.fOp->dumpInfo(), 4).c_str());
|
GrOP_INFO(SkTabString(candidate.fOp->dumpInfo(), 4).c_str());
|
||||||
GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, candidate.fOp.get(), op.get());
|
GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, candidate.fOp.get(), op.get());
|
||||||
join(&fRecordedOps.fromBack(i).fClippedBounds,
|
|
||||||
fRecordedOps.fromBack(i).fClippedBounds, clippedBounds);
|
|
||||||
return candidate.fOp.get();
|
return candidate.fOp.get();
|
||||||
}
|
}
|
||||||
// Stop going backwards if we would cause a painter's order violation.
|
// Stop going backwards if we would cause a painter's order violation.
|
||||||
const SkRect& candidateBounds = fRecordedOps.fromBack(i).fClippedBounds;
|
if (!can_reorder(fRecordedOps.fromBack(i).fOp->bounds(), op->bounds())) {
|
||||||
if (!can_reorder(candidateBounds, clippedBounds)) {
|
|
||||||
GrOP_INFO("\t\tIntersects with (%s, B%u)\n", candidate.fOp->name(),
|
GrOP_INFO("\t\tIntersects with (%s, B%u)\n", candidate.fOp->name(),
|
||||||
candidate.fOp->uniqueID());
|
candidate.fOp->uniqueID());
|
||||||
break;
|
break;
|
||||||
@ -494,7 +478,7 @@ GrOp* GrRenderTargetOpList::recordOp(std::unique_ptr<GrOp> op,
|
|||||||
GrOP_INFO("\t\tFirstOp\n");
|
GrOP_INFO("\t\tFirstOp\n");
|
||||||
}
|
}
|
||||||
GR_AUDIT_TRAIL_OP_RESULT_NEW(fAuditTrail, op);
|
GR_AUDIT_TRAIL_OP_RESULT_NEW(fAuditTrail, op);
|
||||||
fRecordedOps.emplace_back(std::move(op), clippedBounds, renderTarget);
|
fRecordedOps.emplace_back(std::move(op), renderTarget);
|
||||||
fLastFullClearOp = nullptr;
|
fLastFullClearOp = nullptr;
|
||||||
fLastFullClearRenderTargetID.makeInvalid();
|
fLastFullClearRenderTargetID.makeInvalid();
|
||||||
return fRecordedOps.back().fOp.get();
|
return fRecordedOps.back().fOp.get();
|
||||||
@ -511,7 +495,6 @@ void GrRenderTargetOpList::forwardCombine() {
|
|||||||
if (!renderTarget) {
|
if (!renderTarget) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const SkRect& opBounds = fRecordedOps[i].fClippedBounds;
|
|
||||||
int maxCandidateIdx = SkTMin(i + fMaxOpLookahead, fRecordedOps.count() - 1);
|
int maxCandidateIdx = SkTMin(i + fMaxOpLookahead, fRecordedOps.count() - 1);
|
||||||
int j = i + 1;
|
int j = i + 1;
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -534,12 +517,10 @@ void GrRenderTargetOpList::forwardCombine() {
|
|||||||
candidate.fOp->uniqueID());
|
candidate.fOp->uniqueID());
|
||||||
GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, op, candidate.fOp.get());
|
GR_AUDIT_TRAIL_OPS_RESULT_COMBINED(fAuditTrail, op, candidate.fOp.get());
|
||||||
fRecordedOps[j].fOp = std::move(fRecordedOps[i].fOp);
|
fRecordedOps[j].fOp = std::move(fRecordedOps[i].fOp);
|
||||||
join(&fRecordedOps[j].fClippedBounds, fRecordedOps[j].fClippedBounds, opBounds);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Stop going traversing if we would cause a painter's order violation.
|
// Stop going traversing if we would cause a painter's order violation.
|
||||||
const SkRect& candidateBounds = fRecordedOps[j].fClippedBounds;
|
if (!can_reorder(fRecordedOps[j].fOp->bounds(), op->bounds())) {
|
||||||
if (!can_reorder(candidateBounds, opBounds)) {
|
|
||||||
GrOP_INFO("\t\tIntersects with (%s, B%u)\n", candidate.fOp->name(),
|
GrOP_INFO("\t\tIntersects with (%s, B%u)\n", candidate.fOp->name(),
|
||||||
candidate.fOp->uniqueID());
|
candidate.fOp->uniqueID());
|
||||||
break;
|
break;
|
||||||
|
@ -132,13 +132,7 @@ private:
|
|||||||
|
|
||||||
// If the input op is combined with an earlier op, this returns the combined op. Otherwise, it
|
// If the input op is combined with an earlier op, this returns the combined op. Otherwise, it
|
||||||
// returns the input op.
|
// returns the input op.
|
||||||
GrOp* recordOp(std::unique_ptr<GrOp> op, GrRenderTargetContext* renderTargetContext) {
|
GrOp* recordOp(std::unique_ptr<GrOp>, GrRenderTargetContext*);
|
||||||
SkRect bounds = op->bounds();
|
|
||||||
return this->recordOp(std::move(op), renderTargetContext, bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Variant that allows an explicit bounds (computed from the Op's bounds and a clip).
|
|
||||||
GrOp* recordOp(std::unique_ptr<GrOp>, GrRenderTargetContext*, const SkRect& clippedBounds);
|
|
||||||
|
|
||||||
void forwardCombine();
|
void forwardCombine();
|
||||||
|
|
||||||
@ -154,10 +148,9 @@ private:
|
|||||||
void clearStencilClip(const GrFixedClip&, bool insideStencilMask, GrRenderTargetContext*);
|
void clearStencilClip(const GrFixedClip&, bool insideStencilMask, GrRenderTargetContext*);
|
||||||
|
|
||||||
struct RecordedOp {
|
struct RecordedOp {
|
||||||
RecordedOp(std::unique_ptr<GrOp> op, const SkRect& clippedBounds, GrRenderTarget* rt)
|
RecordedOp(std::unique_ptr<GrOp> op, GrRenderTarget* rt)
|
||||||
: fOp(std::move(op)), fClippedBounds(clippedBounds), fRenderTarget(rt) {}
|
: fOp(std::move(op)), fRenderTarget(rt) {}
|
||||||
std::unique_ptr<GrOp> fOp;
|
std::unique_ptr<GrOp> fOp;
|
||||||
SkRect fClippedBounds;
|
|
||||||
// TODO: These ops will all to target the same render target and this won't be needed.
|
// TODO: These ops will all to target the same render target and this won't be needed.
|
||||||
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
|
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
|
||||||
};
|
};
|
||||||
|
@ -65,7 +65,7 @@ bool GrTextureOpList::executeOps(GrOpFlushState* flushState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < fRecordedOps.count(); ++i) {
|
for (int i = 0; i < fRecordedOps.count(); ++i) {
|
||||||
fRecordedOps[i]->execute(flushState, fRecordedOps[i]->bounds());
|
fRecordedOps[i]->execute(flushState);
|
||||||
}
|
}
|
||||||
|
|
||||||
fGpu->finishOpList();
|
fGpu->finishOpList();
|
||||||
|
@ -454,7 +454,7 @@ void InstancedRendering::beginFlush(GrResourceProvider* rp) {
|
|||||||
this->onBeginFlush(rp);
|
this->onBeginFlush(rp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstancedRendering::Op::onExecute(GrOpFlushState* state, const SkRect& bounds) {
|
void InstancedRendering::Op::onExecute(GrOpFlushState* state) {
|
||||||
SkASSERT(State::kFlushing == fInstancedRendering->fState);
|
SkASSERT(State::kFlushing == fInstancedRendering->fState);
|
||||||
SkASSERT(state->gpu() == fInstancedRendering->gpu());
|
SkASSERT(state->gpu() == fInstancedRendering->gpu());
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ protected:
|
|||||||
void applyPipelineOptimizations(const GrPipelineOptimizations&) override;
|
void applyPipelineOptimizations(const GrPipelineOptimizations&) override;
|
||||||
bool onCombineIfPossible(GrOp* other, const GrCaps& caps) override;
|
bool onCombineIfPossible(GrOp* other, const GrCaps& caps) override;
|
||||||
void onPrepare(GrOpFlushState*) override {}
|
void onPrepare(GrOpFlushState*) override {}
|
||||||
void onExecute(GrOpFlushState*, const SkRect& bounds) override;
|
void onExecute(GrOpFlushState*) override;
|
||||||
|
|
||||||
typedef GrDrawOp INHERITED;
|
typedef GrDrawOp INHERITED;
|
||||||
|
|
||||||
|
@ -136,22 +136,6 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) const {
|
|||||||
// now copy all vertices
|
// now copy all vertices
|
||||||
memcpy(currVertex, blobVertices, byteCount);
|
memcpy(currVertex, blobVertices, byteCount);
|
||||||
|
|
||||||
#ifdef SK_DEBUG
|
|
||||||
// bounds sanity check
|
|
||||||
SkRect rect;
|
|
||||||
rect.setLargestInverted();
|
|
||||||
SkPoint* vertex = (SkPoint*)((char*)blobVertices);
|
|
||||||
rect.growToInclude(vertex, vertexStride, kVerticesPerGlyph * subRunGlyphCount);
|
|
||||||
|
|
||||||
if (this->usesDistanceFields()) {
|
|
||||||
args.fViewMatrix.mapRect(&rect);
|
|
||||||
}
|
|
||||||
// Allow for small numerical error in the bounds.
|
|
||||||
SkRect bounds = this->bounds();
|
|
||||||
bounds.outset(0.001f, 0.001f);
|
|
||||||
SkASSERT(bounds.contains(rect));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
currVertex += byteCount;
|
currVertex += byteCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ private:
|
|||||||
|
|
||||||
void onPrepare(GrOpFlushState*) override {}
|
void onPrepare(GrOpFlushState*) override {}
|
||||||
|
|
||||||
void onExecute(GrOpFlushState* state, const SkRect& /*bounds*/) override {
|
void onExecute(GrOpFlushState* state) override {
|
||||||
state->commandBuffer()->clear(fRenderTarget.get(), fClip, fColor);
|
state->commandBuffer()->clear(fRenderTarget.get(), fClip, fColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ private:
|
|||||||
|
|
||||||
void onPrepare(GrOpFlushState*) override {}
|
void onPrepare(GrOpFlushState*) override {}
|
||||||
|
|
||||||
void onExecute(GrOpFlushState* state, const SkRect& /*bounds*/) override {
|
void onExecute(GrOpFlushState* state) override {
|
||||||
state->commandBuffer()->clearStencilClip(fRenderTarget.get(), fClip, fInsideStencilMask);
|
state->commandBuffer()->clearStencilClip(fRenderTarget.get(), fClip, fInsideStencilMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ private:
|
|||||||
|
|
||||||
void onPrepare(GrOpFlushState*) override {}
|
void onPrepare(GrOpFlushState*) override {}
|
||||||
|
|
||||||
void onExecute(GrOpFlushState* state, const SkRect& /*bounds*/) override {
|
void onExecute(GrOpFlushState* state) override {
|
||||||
if (!state->commandBuffer()) {
|
if (!state->commandBuffer()) {
|
||||||
state->gpu()->copySurface(fDst.get(), fSrc.get(), fSrcRect, fDstPoint);
|
state->gpu()->copySurface(fDst.get(), fSrc.get(), fSrcRect, fDstPoint);
|
||||||
} else {
|
} else {
|
||||||
|
@ -41,7 +41,7 @@ private:
|
|||||||
|
|
||||||
void onPrepare(GrOpFlushState*) override {}
|
void onPrepare(GrOpFlushState*) override {}
|
||||||
|
|
||||||
void onExecute(GrOpFlushState* state, const SkRect& /*bounds*/) override {
|
void onExecute(GrOpFlushState* state) override {
|
||||||
state->commandBuffer()->discard(fRenderTarget.get());
|
state->commandBuffer()->discard(fRenderTarget.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ SkString GrDrawPathOp::dumpInfo() const {
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrDrawPathOp::onExecute(GrOpFlushState* state, const SkRect& bounds) {
|
void GrDrawPathOp::onExecute(GrOpFlushState* state) {
|
||||||
GrProgramDesc desc;
|
GrProgramDesc desc;
|
||||||
|
|
||||||
sk_sp<GrPathProcessor> pathProc(
|
sk_sp<GrPathProcessor> pathProc(
|
||||||
@ -115,7 +115,7 @@ bool GrDrawPathRangeOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrDrawPathRangeOp::onExecute(GrOpFlushState* state, const SkRect& bounds) {
|
void GrDrawPathRangeOp::onExecute(GrOpFlushState* state) {
|
||||||
const Draw& head = *fDraws.head();
|
const Draw& head = *fDraws.head();
|
||||||
|
|
||||||
SkMatrix drawMatrix(this->viewMatrix());
|
SkMatrix drawMatrix(this->viewMatrix());
|
||||||
|
@ -78,7 +78,7 @@ private:
|
|||||||
|
|
||||||
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; }
|
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override { return false; }
|
||||||
|
|
||||||
void onExecute(GrOpFlushState* state, const SkRect& bounds) override;
|
void onExecute(GrOpFlushState* state) override;
|
||||||
|
|
||||||
GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
|
GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ private:
|
|||||||
|
|
||||||
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override;
|
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override;
|
||||||
|
|
||||||
void onExecute(GrOpFlushState* state, const SkRect& bounds) override;
|
void onExecute(GrOpFlushState* state) override;
|
||||||
|
|
||||||
struct Draw {
|
struct Draw {
|
||||||
void set(const InstanceData* instanceData, SkScalar x, SkScalar y) {
|
void set(const InstanceData* instanceData, SkScalar x, SkScalar y) {
|
||||||
|
@ -59,7 +59,7 @@ void* GrMeshDrawOp::QuadHelper::init(Target* target, size_t vertexStride, int qu
|
|||||||
quadsToDraw);
|
quadsToDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrMeshDrawOp::onExecute(GrOpFlushState* state, const SkRect& bounds) {
|
void GrMeshDrawOp::onExecute(GrOpFlushState* state) {
|
||||||
int currUploadIdx = 0;
|
int currUploadIdx = 0;
|
||||||
int currMeshIdx = 0;
|
int currMeshIdx = 0;
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ void GrMeshDrawOp::onExecute(GrOpFlushState* state, const SkRect& bounds) {
|
|||||||
}
|
}
|
||||||
const QueuedDraw& draw = fQueuedDraws[currDrawIdx];
|
const QueuedDraw& draw = fQueuedDraws[currDrawIdx];
|
||||||
state->commandBuffer()->draw(*this->pipeline(), *draw.fGeometryProcessor.get(),
|
state->commandBuffer()->draw(*this->pipeline(), *draw.fGeometryProcessor.get(),
|
||||||
fMeshes.begin() + currMeshIdx, draw.fMeshCnt, bounds);
|
fMeshes.begin() + currMeshIdx, draw.fMeshCnt, this->bounds());
|
||||||
currMeshIdx += draw.fMeshCnt;
|
currMeshIdx += draw.fMeshCnt;
|
||||||
state->flushToken();
|
state->flushToken();
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void onPrepare(GrOpFlushState* state) final;
|
void onPrepare(GrOpFlushState* state) final;
|
||||||
void onExecute(GrOpFlushState* state, const SkRect& bounds) final;
|
void onExecute(GrOpFlushState* state) final;
|
||||||
|
|
||||||
virtual void onPrepareDraws(Target*) const = 0;
|
virtual void onPrepareDraws(Target*) const = 0;
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ GrOp::GrOp(uint32_t classID)
|
|||||||
: fClassID(classID)
|
: fClassID(classID)
|
||||||
, fUniqueID(kIllegalOpID) {
|
, fUniqueID(kIllegalOpID) {
|
||||||
SkASSERT(classID == SkToU32(fClassID));
|
SkASSERT(classID == SkToU32(fClassID));
|
||||||
SkDEBUGCODE(fUsed = false;)
|
|
||||||
SkDEBUGCODE(fBoundsFlags = kUninitialized_BoundsFlag);
|
SkDEBUGCODE(fBoundsFlags = kUninitialized_BoundsFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,12 @@ public:
|
|||||||
return fBounds;
|
return fBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setClippedBounds(const SkRect& clippedBounds) {
|
||||||
|
fBounds = clippedBounds;
|
||||||
|
// The clipped bounds already incorporate any effect of the bounds flags.
|
||||||
|
fBoundsFlags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool hasAABloat() const {
|
bool hasAABloat() const {
|
||||||
SkASSERT(fBoundsFlags != kUninitialized_BoundsFlag);
|
SkASSERT(fBoundsFlags != kUninitialized_BoundsFlag);
|
||||||
return SkToBool(fBoundsFlags & kAABloat_BoundsFlag);
|
return SkToBool(fBoundsFlags & kAABloat_BoundsFlag);
|
||||||
@ -118,7 +124,6 @@ public:
|
|||||||
}
|
}
|
||||||
return fUniqueID;
|
return fUniqueID;
|
||||||
}
|
}
|
||||||
SkDEBUGCODE(bool isUsed() const { return fUsed; })
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called prior to executing. The op should perform any resource creation or data transfers
|
* Called prior to executing. The op should perform any resource creation or data transfers
|
||||||
@ -127,7 +132,7 @@ public:
|
|||||||
void prepare(GrOpFlushState* state) { this->onPrepare(state); }
|
void prepare(GrOpFlushState* state) { this->onPrepare(state); }
|
||||||
|
|
||||||
/** Issues the op's commands to GrGpu. */
|
/** Issues the op's commands to GrGpu. */
|
||||||
void execute(GrOpFlushState* state, const SkRect& bounds) { this->onExecute(state, bounds); }
|
void execute(GrOpFlushState* state) { this->onExecute(state); }
|
||||||
|
|
||||||
/** Used for spewing information about ops when debugging. */
|
/** Used for spewing information about ops when debugging. */
|
||||||
virtual SkString dumpInfo() const {
|
virtual SkString dumpInfo() const {
|
||||||
@ -186,7 +191,7 @@ private:
|
|||||||
virtual bool onCombineIfPossible(GrOp*, const GrCaps& caps) = 0;
|
virtual bool onCombineIfPossible(GrOp*, const GrCaps& caps) = 0;
|
||||||
|
|
||||||
virtual void onPrepare(GrOpFlushState*) = 0;
|
virtual void onPrepare(GrOpFlushState*) = 0;
|
||||||
virtual void onExecute(GrOpFlushState*, const SkRect& bounds) = 0;
|
virtual void onExecute(GrOpFlushState*) = 0;
|
||||||
|
|
||||||
static uint32_t GenID(int32_t* idCounter) {
|
static uint32_t GenID(int32_t* idCounter) {
|
||||||
// The atomic inc returns the old value not the incremented value. So we add
|
// The atomic inc returns the old value not the incremented value. So we add
|
||||||
@ -215,7 +220,6 @@ private:
|
|||||||
SkDEBUGCODE(kUninitialized_BoundsFlag = 0x4)
|
SkDEBUGCODE(kUninitialized_BoundsFlag = 0x4)
|
||||||
};
|
};
|
||||||
|
|
||||||
SkDEBUGCODE(bool fUsed;)
|
|
||||||
const uint16_t fClassID;
|
const uint16_t fClassID;
|
||||||
uint16_t fBoundsFlags;
|
uint16_t fBoundsFlags;
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ private:
|
|||||||
|
|
||||||
void onPrepare(GrOpFlushState*) override {}
|
void onPrepare(GrOpFlushState*) override {}
|
||||||
|
|
||||||
void onExecute(GrOpFlushState* state, const SkRect& bounds) override {
|
void onExecute(GrOpFlushState* state) override {
|
||||||
GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fViewMatrix,
|
GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fViewMatrix,
|
||||||
&fScissor, &fStencil);
|
&fScissor, &fStencil);
|
||||||
state->gpu()->pathRendering()->stencilPath(args, fPath.get());
|
state->gpu()->pathRendering()->stencilPath(args, fPath.get());
|
||||||
|
Loading…
Reference in New Issue
Block a user