Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(801)

Unified Diff: src/gpu/GrDrawTarget.cpp

Issue 13222004: Trim the copy of the dst made for dst-reading effects using the clip and dev-bounds of draw. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrOvalRenderer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawTarget.cpp
===================================================================
--- src/gpu/GrDrawTarget.cpp (revision 8451)
+++ src/gpu/GrDrawTarget.cpp (working copy)
@@ -407,15 +407,7 @@
}
bool GrDrawTarget::setupDstReadIfNecessary(DrawInfo* info) {
- bool willReadDst = false;
- for (int s = 0; s < GrDrawState::kNumStages; ++s) {
- const GrEffectRef* effect = this->drawState()->getStage(s).getEffect();
- if (NULL != effect && (*effect)->willReadDst()) {
- willReadDst = true;
- break;
- }
- }
- if (!willReadDst) {
+ if (!this->getDrawState().willEffectReadDst()) {
return true;
}
GrRenderTarget* rt = this->drawState()->getRenderTarget();
@@ -426,8 +418,24 @@
GrPrintf("Reading Dst of non-texture render target is not currently supported.\n");
return false;
}
- // TODO: Consider bounds of draw and bounds of clip
+ const GrClipData* clip = this->getClip();
+ GrIRect copyRect;
+ clip->getConservativeBounds(this->getDrawState().getRenderTarget(), &copyRect);
+ SkIRect drawIBounds;
+ if (info->getDevIBounds(&drawIBounds)) {
+ if (!copyRect.intersect(drawIBounds)) {
+#if GR_DEBUG
+ GrPrintf("Missed an early reject. Bailing on draw from setupDstReadIfNecessary.\n");
+#endif
+ return false;
+ }
+ } else {
+#if GR_DEBUG
+ //GrPrintf("No dev bounds when dst copy is made.\n");
+#endif
+ }
+
GrDrawTarget::AutoGeometryAndStatePush agasp(this, kReset_ASRInit);
// The draw will resolve dst if it has MSAA. Two things to consider in the future:
@@ -437,8 +445,8 @@
// copy of it.
GrTextureDesc desc;
desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
- desc.fWidth = rt->width();
- desc.fHeight = rt->height();
+ desc.fWidth = copyRect.width();
+ desc.fHeight = copyRect.height();
desc.fSampleCnt = 0;
desc.fConfig = rt->config();
@@ -454,11 +462,14 @@
SkMatrix matrix;
matrix.setIDiv(rt->width(), rt->height());
this->drawState()->createTextureEffect(kTextureStage, rt->asTexture(), matrix);
- SkRect copyRect = SkRect::MakeWH(SkIntToScalar(desc.fWidth),
- SkIntToScalar(desc.fHeight));
- this->drawRect(copyRect, NULL, &copyRect, NULL);
+
+ SkRect srcRect = SkRect::MakeFromIRect(copyRect);
+ SkRect dstRect = SkRect::MakeWH(SkIntToScalar(copyRect.width()),
+ SkIntToScalar(copyRect.height()));
+ this->drawRect(dstRect, NULL, &srcRect, NULL);
+
info->fDstCopy.setTexture(ast.texture());
- info->fDstCopy.setOffset(0, 0);
+ info->fDstCopy.setOffset(copyRect.fLeft, copyRect.fTop);
return true;
}
@@ -645,8 +656,13 @@
localMatrix->mapPointsWithStride(coords, vsize, 4);
}
}
+ SkTLazy<SkRect> bounds;
+ if (this->getDrawState().willEffectReadDst()) {
+ bounds.init();
+ this->getDrawState().getViewMatrix().mapRect(bounds.get(), rect);
+ }
- this->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4);
+ this->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4, bounds.getMaybeNull());
}
void GrDrawTarget::clipWillBeSet(const GrClipData* clipData) {
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrOvalRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698