Move the msaa dirty rect to GrRenderTargetProxy
Bug: skia:
Change-Id: I01d7932bce23dffafb86e4eb124c27420acefdd3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/239192
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index c7e004d..cb80efa 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -19,6 +19,7 @@
#include "src/gpu/GrDataUtils.h"
#include "src/gpu/GrGpuResourcePriv.h"
#include "src/gpu/GrMesh.h"
+#include "src/gpu/GrNativeRect.h"
#include "src/gpu/GrPathRendering.h"
#include "src/gpu/GrPipeline.h"
#include "src/gpu/GrRenderTargetPriv.h"
@@ -580,8 +581,14 @@
SkASSERT(texture);
SkASSERT(this->caps()->mipMapSupport());
SkASSERT(texture->texturePriv().mipMapped() == GrMipMapped::kYes);
- SkASSERT(texture->texturePriv().mipMapsAreDirty());
SkASSERT(!texture->asRenderTarget() || !texture->asRenderTarget()->needsResolve());
+ if (!texture->texturePriv().mipMapsAreDirty()) {
+ // This can happen when the proxy expects mipmaps to be dirty, but they are not dirty on the
+ // actual target. This may be caused by things that the drawingManager could not predict,
+ // i.e., ops that don't draw anything, aborting a draw for exceptional circumstances, etc.
+ // NOTE: This goes away once we quit tracking mipmap state on the actual texture.
+ return true;
+ }
if (texture->readOnly()) {
return false;
}
@@ -597,10 +604,24 @@
this->onResetTextureBindings();
}
-void GrGpu::resolveRenderTarget(GrRenderTarget* target, ForExternalIO forExternalIO) {
+void GrGpu::resolveRenderTarget(GrRenderTarget* target, const SkIRect& resolveRect,
+ GrSurfaceOrigin origin, ForExternalIO forExternalIO) {
SkASSERT(target);
+ if (!target->needsResolve()) {
+ // This can happen when the proxy expects MSAA to be dirty, but it is not dirty on the
+ // actual target. This may be caused by things that the drawingManager could not predict,
+ // i.e., ops that don't draw anything, aborting a draw for exceptional circumstances, etc.
+ // NOTE: This goes away once we quit tracking dirty state on the actual render target.
+ return;
+ }
+#ifdef SK_DEBUG
+ auto nativeResolveRect = GrNativeRect::MakeRelativeTo(origin, target->height(), resolveRect);
+ // The proxy will often track a tighter resolve rect than GrRenderTarget, but it should never be
+ // the other way around.
+ SkASSERT(target->getResolveRect().contains(nativeResolveRect.asSkIRect()));
+#endif
this->handleDirtyContext();
- this->onResolveRenderTarget(target, forExternalIO);
+ this->onResolveRenderTarget(target, resolveRect, origin, forExternalIO);
}
void GrGpu::didWriteToSurface(GrSurface* surface, GrSurfaceOrigin origin, const SkIRect* bounds,