OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrBatchTest.h" | 9 #include "GrBatchTest.h" |
10 #include "GrColor.h" | 10 #include "GrColor.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 // Will it blend? | 261 // Will it blend? |
262 GrColor clearColor; | 262 GrColor clearColor; |
263 if (paint.isConstantBlendedColor(&clearColor)) { | 263 if (paint.isConstantBlendedColor(&clearColor)) { |
264 this->getDrawTarget()->clear(nullptr, clearColor, true, fRen
derTarget); | 264 this->getDrawTarget()->clear(nullptr, clearColor, true, fRen
derTarget); |
265 return; | 265 return; |
266 } | 266 } |
267 } | 267 } |
268 } | 268 } |
269 } | 269 } |
270 | 270 |
| 271 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); |
271 GrColor color = paint.getColor(); | 272 GrColor color = paint.getColor(); |
272 bool needAA = should_apply_coverage_aa(paint, fRenderTarget); | |
273 | 273 |
274 // The fill path can handle rotation but not skew | 274 if (should_apply_coverage_aa(paint, fRenderTarget)) { |
275 // The stroke path needs the rect to remain axis aligned (no rotation or ske
w) | |
276 // None of our AA draw rect calls can handle perspective yet | |
277 bool canApplyAA = width >=0 ? viewMatrix.rectStaysRect() : | |
278 view_matrix_ok_for_aa_fill_rect(viewMatrix); | |
279 | |
280 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | |
281 | |
282 if (needAA && canApplyAA) { | |
283 SkASSERT(!viewMatrix.hasPerspective()); | |
284 SkAutoTUnref<GrDrawBatch> batch; | 275 SkAutoTUnref<GrDrawBatch> batch; |
285 if (width >= 0) { | 276 if (width >= 0) { |
286 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, re
ct, *strokeInfo)); | 277 // The stroke path needs the rect to remain axis aligned (no rotatio
n or skew). |
| 278 if (viewMatrix.rectStaysRect()) { |
| 279 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix
, rect, |
| 280 *strokeInfo)); |
| 281 } |
287 } else { | 282 } else { |
288 SkRect devBoundRect; | 283 // The fill path can handle rotation but not skew. |
289 viewMatrix.mapRect(&devBoundRect, rect); | 284 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
290 batch.reset(GrRectBatchFactory::CreateAAFill(color, viewMatrix, rect
, devBoundRect)); | 285 SkRect devBoundRect; |
| 286 viewMatrix.mapRect(&devBoundRect, rect); |
| 287 batch.reset(GrRectBatchFactory::CreateAAFill(color, viewMatrix,
rect, |
| 288 devBoundRect)); |
| 289 } |
291 } | 290 } |
292 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 291 if (batch) { |
| 292 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 293 } else { |
| 294 SkPath path; |
| 295 path.setIsVolatile(true); |
| 296 path.addRect(rect); |
| 297 this->internalDrawPath(&pipelineBuilder, viewMatrix, color, true, pa
th, *strokeInfo); |
| 298 SkASSERT(paint.isAntiAlias()); |
| 299 } |
293 return; | 300 return; |
294 } | 301 } |
295 | 302 |
296 if (width >= 0) { | 303 if (width >= 0) { |
297 // Non-AA hairlines are snapped to pixel centers to make which pixels ar
e hit deterministic | 304 // Non-AA hairlines are snapped to pixel centers to make which pixels ar
e hit deterministic |
298 bool snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultis
ampled()); | 305 bool snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultis
ampled()); |
299 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAStroke( | 306 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAStroke( |
300 color, viewMatrix, rect, width, snapToPi
xelCenters)); | 307 color, viewMatrix, rect, width, snapToPi
xelCenters)); |
301 | 308 |
302 // Depending on sub-pixel coordinates and the particular GPU, we may los
e a corner of | 309 // Depending on sub-pixel coordinates and the particular GPU, we may los
e a corner of |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 args.fAntiAlias = useCoverageAA; | 798 args.fAntiAlias = useCoverageAA; |
792 pr->drawPath(args); | 799 pr->drawPath(args); |
793 } | 800 } |
794 | 801 |
795 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { | 802 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { |
796 RETURN_IF_ABANDONED | 803 RETURN_IF_ABANDONED |
797 SkDEBUGCODE(this->validate();) | 804 SkDEBUGCODE(this->validate();) |
798 | 805 |
799 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); | 806 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); |
800 } | 807 } |
OLD | NEW |