Revert "Abolish absClear"
This reverts commit f948db6228fd8dce2ba2a6ff2dfec53ff95d3f90.
Reason for revert: Vulkan assertion on Nexus5
Original change's description:
> Abolish absClear
>
> Bug: skia:
> Change-Id: Ic4a0e640623677c06112d0735ffc5682049baf11
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/240771
> Commit-Queue: Chris Dalton <csmartdalton@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,csmartdalton@google.com,michaelludwig@google.com
Change-Id: I071c9878d26ce0f1d91473ada48e9a702bb472de
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/242480
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index def18a3..dd3472c 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -341,6 +341,81 @@
}
}
+void GrRenderTargetContextPriv::absClear(const SkIRect* clearRect) {
+ ASSERT_SINGLE_OWNER_PRIV
+ RETURN_IF_ABANDONED_PRIV
+ SkDEBUGCODE(fRenderTargetContext->validate();)
+ GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContextPriv", "absClear",
+ fRenderTargetContext->fContext);
+
+ AutoCheckFlush acf(fRenderTargetContext->drawingManager());
+
+ SkIRect rtRect = SkIRect::MakeWH(fRenderTargetContext->fRenderTargetProxy->worstCaseWidth(),
+ fRenderTargetContext->fRenderTargetProxy->worstCaseHeight());
+
+ if (clearRect) {
+ if (clearRect->contains(rtRect)) {
+ clearRect = nullptr; // full screen
+ } else {
+ if (!rtRect.intersect(*clearRect)) {
+ return;
+ }
+ }
+ }
+
+ static const SkPMColor4f kColor = SK_PMColor4fTRANSPARENT;
+
+ // TODO: in a post-MDB world this should be handled at the OpsTask level.
+ // This makes sure to always add an op to the list, instead of marking the clear as a load op.
+ // This code follows very similar logic to internalClear() below, but critical differences are
+ // highlighted in line related to absClear()'s unique behavior.
+ if (clearRect) {
+ if (fRenderTargetContext->caps()->performPartialClearsAsDraws()) {
+ GrPaint paint;
+ clear_to_grpaint(kColor, &paint);
+
+ // Use the disabled clip; the rect geometry already matches the clear rectangle and
+ // if it were added to a scissor, that would be intersected with the logical surface
+ // bounds and not the worst case dimensions required here.
+ fRenderTargetContext->addDrawOp(
+ GrFixedClip::Disabled(),
+ GrFillRectOp::MakeNonAARect(fRenderTargetContext->fContext, std::move(paint),
+ SkMatrix::I(), SkRect::Make(rtRect)));
+ } else {
+ // Must use the ClearOp factory that takes a boolean (false) instead of a surface
+ // proxy. The surface proxy variant would intersect the clip rect with its logical
+ // bounds, which is not desired in this special case.
+ fRenderTargetContext->addOp(GrClearOp::Make(
+ fRenderTargetContext->fContext, rtRect, kColor, /* fullscreen */ false));
+ }
+ } else {
+ if (fRenderTargetContext->getOpsTask()->resetForFullscreenClear(
+ fRenderTargetContext->canDiscardPreviousOpsOnFullClear()) &&
+ !fRenderTargetContext->caps()->performColorClearsAsDraws()) {
+ fRenderTargetContext->getOpsTask()->setColorLoadOp(GrLoadOp::kClear, kColor);
+ } else {
+ fRenderTargetContext->getOpsTask()->setColorLoadOp(GrLoadOp::kDiscard);
+
+ if (fRenderTargetContext->caps()->performColorClearsAsDraws()) {
+ // This draws a quad covering the worst case dimensions instead of just the logical
+ // width and height like in internalClear().
+ GrPaint paint;
+ clear_to_grpaint(kColor, &paint);
+ fRenderTargetContext->addDrawOp(
+ GrFixedClip::Disabled(),
+ GrFillRectOp::MakeNonAARect(fRenderTargetContext->fContext,
+ std::move(paint), SkMatrix::I(),
+ SkRect::Make(rtRect)));
+ } else {
+ // Nothing special about this path in absClear compared to internalClear()
+ fRenderTargetContext->addOp(GrClearOp::Make(
+ fRenderTargetContext->fContext, SkIRect::MakeEmpty(), kColor,
+ /* fullscreen */ true));
+ }
+ }
+ }
+}
+
void GrRenderTargetContext::drawPaint(const GrClip& clip,
GrPaint&& paint,
const SkMatrix& viewMatrix) {