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

Unified Diff: src/gpu/GrDrawContext.cpp

Issue 2183223002: Implement coverage AA for skewed rects with local coords (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Implement coverage AA for skewed rects with local coords 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 | « no previous file | 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 48242e278f079dbedda890a360f69a1a8f33c0f3..9cf68ae2f3bb91809590ace498f3e663ede86bcf 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -616,12 +616,12 @@ void GrDrawContext::fillRectToRect(const GrClip& clip,
}
AutoCheckFlush acf(fDrawingManager);
- SkAutoTUnref<GrDrawBatch> batch;
bool useHWAA;
if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) {
- batch.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), croppedLocalRect,
- paint.isAntiAlias(), fInstancedPipelineInfo, &useHWAA));
+ SkAutoTUnref<GrDrawBatch> batch(ir->recordRect(croppedRect, viewMatrix, paint.getColor(),
+ croppedLocalRect, paint.isAntiAlias(),
+ fInstancedPipelineInfo, &useHWAA));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
@@ -629,20 +629,33 @@ void GrDrawContext::fillRectToRect(const GrClip& clip,
}
}
- 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));
- if (batch) {
- GrPipelineBuilder pipelineBuilder(paint, useHWAA);
- this->drawBatch(pipelineBuilder, clip, batch);
- return;
- }
- } else {
+ if (!should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) {
this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, &croppedLocalRect,
nullptr, nullptr);
+ return;
+ }
+
+ if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
+ SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(),
+ viewMatrix,
+ croppedRect,
+ croppedLocalRect));
+ GrPipelineBuilder pipelineBuilder(paint, useHWAA);
+ this->drawBatch(pipelineBuilder, clip, batch);
+ return;
+ }
+
+ SkMatrix viewAndUnLocalMatrix;
+ if (!viewAndUnLocalMatrix.setRectToRect(localRect, rectToDraw, SkMatrix::kFill_ScaleToFit)) {
+ SkDebugf("fillRectToRect called with empty local matrix.\n");
+ return;
}
+ viewAndUnLocalMatrix.postConcat(viewMatrix);
+ SkPath path;
+ path.setIsVolatile(true);
+ path.addRect(localRect);
+ this->internalDrawPath(clip, paint, viewAndUnLocalMatrix, path, GrStyle());
}
void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip,
@@ -661,12 +674,12 @@ void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip,
}
AutoCheckFlush acf(fDrawingManager);
- SkAutoTUnref<GrDrawBatch> batch;
bool useHWAA;
if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) {
- batch.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), localMatrix,
- paint.isAntiAlias(), fInstancedPipelineInfo, &useHWAA));
+ SkAutoTUnref<GrDrawBatch> batch(ir->recordRect(croppedRect, viewMatrix, paint.getColor(),
+ localMatrix, paint.isAntiAlias(),
+ fInstancedPipelineInfo, &useHWAA));
if (batch) {
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
@@ -674,17 +687,32 @@ void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip,
}
}
- 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));
- GrPipelineBuilder pipelineBuilder(paint, useHWAA);
- this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
- } else {
+ if (!should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) {
this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr,
&localMatrix, nullptr);
+ return;
}
+ if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
+ SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix,
+ localMatrix, croppedRect));
+ GrPipelineBuilder pipelineBuilder(paint, useHWAA);
+ this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
+ return;
+ }
+
+ SkMatrix viewAndUnLocalMatrix;
+ if (!localMatrix.invert(&viewAndUnLocalMatrix)) {
+ SkDebugf("fillRectWithLocalMatrix called with degenerate local matrix.\n");
+ return;
+ }
+ viewAndUnLocalMatrix.postConcat(viewMatrix);
+
+ SkPath path;
+ path.setIsVolatile(true);
+ path.addRect(rectToDraw);
+ path.transform(localMatrix);
+ this->internalDrawPath(clip, paint, viewAndUnLocalMatrix, path, GrStyle());
}
void GrDrawContext::drawVertices(const GrClip& clip,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698