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

Unified Diff: src/gpu/GrDrawContext.cpp

Issue 2140253004: Revert of Pre-crop filled rects to avoid scissor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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/GrClipMaskManager.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawContext.cpp
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 8f012cd65840177ecade6979dec9ff584bd31239..a86e01e72b385328b069f84f412f43bfcc58e604 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -270,70 +270,17 @@
}
}
-// Attempts to crop a rect and optional local rect to the clip boundaries.
-// Returns false if the draw can be skipped entirely.
-static bool crop_filled_rect(const GrRenderTarget* rt, const GrClip& clip,
- const SkMatrix& viewMatrix, SkRect* rect,
- SkRect* localRect = nullptr) {
- if (!viewMatrix.rectStaysRect()) {
- return true;
- }
-
- SkMatrix inverseViewMatrix;
- if (!viewMatrix.invert(&inverseViewMatrix)) {
- return false;
- }
-
- SkIRect clipDevBounds;
- SkRect clipBounds;
- SkASSERT(inverseViewMatrix.rectStaysRect());
-
- clip.getConservativeBounds(rt->width(), rt->height(), &clipDevBounds);
- inverseViewMatrix.mapRect(&clipBounds, SkRect::Make(clipDevBounds));
-
- if (localRect) {
- if (!rect->intersects(clipBounds)) {
- return false;
- }
- const SkScalar dx = localRect->width() / rect->width();
- const SkScalar dy = localRect->height() / rect->height();
- if (clipBounds.fLeft > rect->fLeft) {
- localRect->fLeft += (clipBounds.fLeft - rect->fLeft) * dx;
- rect->fLeft = clipBounds.fLeft;
- }
- if (clipBounds.fTop > rect->fTop) {
- localRect->fTop += (clipBounds.fTop - rect->fTop) * dy;
- rect->fTop = clipBounds.fTop;
- }
- if (clipBounds.fRight < rect->fRight) {
- localRect->fRight -= (rect->fRight - clipBounds.fRight) * dx;
- rect->fRight = clipBounds.fRight;
- }
- if (clipBounds.fBottom < rect->fBottom) {
- localRect->fBottom -= (rect->fBottom - clipBounds.fBottom) * dy;
- rect->fBottom = clipBounds.fBottom;
- }
- return true;
- }
-
- return rect->intersect(clipBounds);
-}
-
bool GrDrawContext::drawFilledRect(const GrClip& clip,
const GrPaint& paint,
const SkMatrix& viewMatrix,
const SkRect& rect,
const GrUserStencilSettings* ss) {
- SkRect croppedRect = rect;
- if (!crop_filled_rect(fRenderTarget.get(), clip, viewMatrix, &croppedRect)) {
- return true;
- }
SkAutoTUnref<GrDrawBatch> batch;
bool useHWAA;
if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) {
- batch.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(),
+ batch.reset(ir->recordRect(rect, viewMatrix, paint.getColor(),
paint.isAntiAlias(), fInstancedPipelineInfo,
&useHWAA));
if (batch) {
@@ -350,10 +297,10 @@
// The fill path can handle rotation but not skew.
if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
SkRect devBoundRect;
- viewMatrix.mapRect(&devBoundRect, croppedRect);
+ viewMatrix.mapRect(&devBoundRect, rect);
batch.reset(GrRectBatchFactory::CreateAAFill(paint.getColor(), viewMatrix,
- croppedRect, devBoundRect));
+ rect, devBoundRect));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
if (ss) {
@@ -364,7 +311,7 @@
}
}
} else {
- this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr, nullptr, ss);
+ this->drawNonAAFilledRect(clip, paint, viewMatrix, rect, nullptr, nullptr, ss);
return true;
}
@@ -575,18 +522,12 @@
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectToRect");
- SkRect croppedRect = rectToDraw;
- SkRect croppedLocalRect = localRect;
- if (!crop_filled_rect(fRenderTarget.get(), clip, viewMatrix, &croppedRect, &croppedLocalRect)) {
- return;
- }
-
AutoCheckFlush acf(fDrawingManager);
SkAutoTUnref<GrDrawBatch> batch;
bool useHWAA;
if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) {
- batch.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), croppedLocalRect,
+ batch.reset(ir->recordRect(rectToDraw, viewMatrix, paint.getColor(), localRect,
paint.isAntiAlias(), fInstancedPipelineInfo, &useHWAA));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
@@ -597,15 +538,15 @@
if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) &&
view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
- batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), viewMatrix,
- croppedRect, croppedLocalRect));
+ batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), viewMatrix, rectToDraw,
+ localRect));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->drawBatch(pipelineBuilder, clip, batch);
return;
}
} else {
- this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, &croppedLocalRect,
+ this->drawNonAAFilledRect(clip, paint, viewMatrix, rectToDraw, &localRect,
nullptr, nullptr);
}
@@ -621,17 +562,12 @@
SkDEBUGCODE(this->validate();)
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatrix");
- SkRect croppedRect = rectToDraw;
- if (!crop_filled_rect(fRenderTarget.get(), clip, viewMatrix, &croppedRect)) {
- return;
- }
-
AutoCheckFlush acf(fDrawingManager);
SkAutoTUnref<GrDrawBatch> batch;
bool useHWAA;
if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) {
- batch.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), localMatrix,
+ batch.reset(ir->recordRect(rectToDraw, viewMatrix, paint.getColor(), localMatrix,
paint.isAntiAlias(), fInstancedPipelineInfo, &useHWAA));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
@@ -643,11 +579,11 @@
if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) &&
view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, localMatrix,
- croppedRect));
+ rectToDraw));
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
} else {
- this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr,
+ this->drawNonAAFilledRect(clip, paint, viewMatrix, rectToDraw, nullptr,
&localMatrix, nullptr);
}
« no previous file with comments | « src/gpu/GrClipMaskManager.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698