aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDrawTarget.cpp
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2015-08-06 10:54:13 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-06 10:54:13 -0700
commit51c8d409ad55a72eceb46ec7b65702d6d540aa4f (patch)
tree4b37a2800d5f057c7577988307e724d85c7a79c0 /src/gpu/GrDrawTarget.cpp
parentb4f9d0ec6cc95ce46f9351fee5adaffcfa729e38 (diff)
Move some work from backend onClear to base class clear
Diffstat (limited to 'src/gpu/GrDrawTarget.cpp')
-rw-r--r--src/gpu/GrDrawTarget.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 0049767e8b..2171f1e934 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -309,14 +309,25 @@ void GrDrawTarget::clear(const SkIRect* rect,
GrColor color,
bool canIgnoreRect,
GrRenderTarget* renderTarget) {
+ SkIRect rtRect = SkIRect::MakeWH(renderTarget->width(), renderTarget->height());
+ SkIRect clippedRect;
+ if (!rect ||
+ (canIgnoreRect && this->caps()->fullClearIsFree()) ||
+ rect->contains(rtRect)) {
+ rect = &rtRect;
+ } else {
+ clippedRect = *rect;
+ if (!clippedRect.intersect(rtRect)) {
+ return;
+ }
+ rect = &clippedRect;
+ }
+
if (fCaps->useDrawInsteadOfClear()) {
// This works around a driver bug with clear by drawing a rect instead.
// The driver will ignore a clear if it is the only thing rendered to a
// target before the target is read.
- SkIRect rtRect = SkIRect::MakeWH(renderTarget->width(), renderTarget->height());
- if (NULL == rect || canIgnoreRect || rect->contains(rtRect)) {
- rect = &rtRect;
- // We first issue a discard() since that may help tilers.
+ if (rect == &rtRect) {
this->discard(renderTarget);
}
@@ -325,7 +336,7 @@ void GrDrawTarget::clear(const SkIRect* rect,
this->drawSimpleRect(pipelineBuilder, color, SkMatrix::I(), *rect);
} else {
- this->onClear(rect, color, canIgnoreRect, renderTarget);
+ this->onClear(*rect, color, renderTarget);
}
}