Revert "Simplify GrRTC::clean APIs"
This reverts commit 6cbd7c2e57af9c499f7e99feb215b890fdd3a10a.
Reason for revert: mac/generated files failures
Original change's description:
> Simplify GrRTC::clean APIs
>
> The CanClearFullscreen enum type is removed. Most usages of clear() had
> kYes because a null scissor rect was provided, or had kNo because the
> scissor was really critical to the behavior. A few places did provide a
> scissor and kYes (e.g. for initializing the target).
>
> To simplify this, the public GrRTC has two variants of clear(). One with
> only a color (for fullscreen clears), and one with a rect for partial
> clears. The private API also adds a clearAtLeast() function that replaces
> the several cases where we'd have a scissor but could expand to fullscreen.
>
> I find the current control flow in internalClear() to be hard to
> follow (albeit I was the one to make it that way...), but later CLs
> will improve it.
>
> Bug: skia:10205
> Change-Id: I87cf8d688c58fbe58ee854fbc4ffe22482d969c6
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290256
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com
Change-Id: I7131df6f5323f4f9c120cbcfd9bc57e627e2eb65
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10205
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291842
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/ops/GrClearOp.cpp b/src/gpu/ops/GrClearOp.cpp
index 753f75d..dc1b939 100644
--- a/src/gpu/ops/GrClearOp.cpp
+++ b/src/gpu/ops/GrClearOp.cpp
@@ -17,22 +17,45 @@
std::unique_ptr<GrClearOp> GrClearOp::Make(GrRecordingContext* context,
const GrScissorState& scissor,
const SkPMColor4f& color,
- const GrSurfaceProxy* dstProxy) {
+ GrSurfaceProxy* dstProxy) {
const SkIRect rect = SkIRect::MakeSize(dstProxy->dimensions());
if (scissor.enabled() && !SkIRect::Intersects(scissor.rect(), rect)) {
return nullptr;
}
GrOpMemoryPool* pool = context->priv().opMemoryPool();
+
return pool->allocate<GrClearOp>(scissor, color, dstProxy);
}
-GrClearOp::GrClearOp(const GrScissorState& scissor, const SkPMColor4f& color,
- const GrSurfaceProxy* proxy)
+std::unique_ptr<GrClearOp> GrClearOp::Make(GrRecordingContext* context,
+ const SkIRect& rect,
+ const SkPMColor4f& color,
+ bool fullScreen) {
+ SkASSERT(fullScreen || !rect.isEmpty());
+
+ GrOpMemoryPool* pool = context->priv().opMemoryPool();
+
+ return pool->allocate<GrClearOp>(rect, color, fullScreen);
+}
+
+GrClearOp::GrClearOp(const GrScissorState& scissor, const SkPMColor4f& color, GrSurfaceProxy* proxy)
: INHERITED(ClassID())
, fScissor(scissor)
, fColor(color) {
- this->setBounds(scissor.enabled() ? SkRect::Make(scissor.rect()) : proxy->getBoundsRect(),
+ const SkIRect rtRect = SkIRect::MakeSize(proxy->dimensions());
+ if (fScissor.enabled()) {
+ // Don't let scissors extend outside the RT. This may improve op combining.
+ if (!fScissor.intersect(rtRect)) {
+ SkASSERT(0); // should be caught upstream
+ fScissor.set(SkIRect::MakeEmpty());
+ }
+
+ if (proxy->isFunctionallyExact() && fScissor.rect() == rtRect) {
+ fScissor.setDisabled();
+ }
+ }
+ this->setBounds(SkRect::Make(fScissor.enabled() ? fScissor.rect() : rtRect),
HasAABloat::kNo, IsHairline::kNo);
}