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

Side by Side Diff: src/gpu/GrDrawContext.cpp

Issue 1310533004: Standardize BW to NonAA (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrDrawTarget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrAtlasTextContext.h" 9 #include "GrAtlasTextContext.h"
10 #include "GrBatchTest.h" 10 #include "GrBatchTest.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 SkDebugf("Could not invert matrix\n"); 188 SkDebugf("Could not invert matrix\n");
189 return; 189 return;
190 } 190 }
191 191
192 AutoCheckFlush acf(fContext); 192 AutoCheckFlush acf(fContext);
193 if (!this->prepareToDraw(rt)) { 193 if (!this->prepareToDraw(rt)) {
194 return; 194 return;
195 } 195 }
196 196
197 GrPipelineBuilder pipelineBuilder(*paint, rt, clip); 197 GrPipelineBuilder pipelineBuilder(*paint, rt, clip);
198 fDrawTarget->drawBWRect(pipelineBuilder, 198 fDrawTarget->drawNonAARect(pipelineBuilder,
199 paint->getColor(), 199 paint->getColor(),
200 SkMatrix::I(), 200 SkMatrix::I(),
201 r, 201 r,
202 localMatrix); 202 localMatrix);
203 } 203 }
204 } 204 }
205 205
206 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) { 206 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) {
207 return point.fX >= rect.fLeft && point.fX <= rect.fRight && 207 return point.fX >= rect.fLeft && point.fX <= rect.fRight &&
208 point.fY >= rect.fTop && point.fY <= rect.fBottom; 208 point.fY >= rect.fTop && point.fY <= rect.fBottom;
209 } 209 }
210 210
211 void GrDrawContext::drawRect(GrRenderTarget* rt, 211 void GrDrawContext::drawRect(GrRenderTarget* rt,
212 const GrClip& clip, 212 const GrClip& clip,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // The stroke path needs the rect to remain axis aligned (no rotation or ske w) 274 // The stroke path needs the rect to remain axis aligned (no rotation or ske w)
275 // None of our draw rect calls can handle perspective yet 275 // None of our draw rect calls can handle perspective yet
276 SkASSERT(!viewMatrix.hasPerspective()); 276 SkASSERT(!viewMatrix.hasPerspective());
277 bool canApplyAA = width >=0 ? viewMatrix.rectStaysRect() : viewMatrix.preser vesRightAngles(); 277 bool canApplyAA = width >=0 ? viewMatrix.rectStaysRect() : viewMatrix.preser vesRightAngles();
278 278
279 if (needAA && canApplyAA) { 279 if (needAA && canApplyAA) {
280 SkRect devBoundRect; 280 SkRect devBoundRect;
281 viewMatrix.mapRect(&devBoundRect, rect); 281 viewMatrix.mapRect(&devBoundRect, rect);
282 SkAutoTUnref<GrDrawBatch> batch; 282 SkAutoTUnref<GrDrawBatch> batch;
283 if (width >= 0) { 283 if (width >= 0) {
284 batch.reset(GrRectBatchFactory::CreateStrokeAA(color, viewMatrix, re ct, devBoundRect, 284 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, re ct, devBoundRect,
285 *strokeInfo)); 285 *strokeInfo));
286 } else { 286 } else {
287 batch.reset(GrRectBatchFactory::CreateFillAA(color, viewMatrix, rect , devBoundRect)); 287 batch.reset(GrRectBatchFactory::CreateAAFill(color, viewMatrix, rect , devBoundRect));
288 } 288 }
289 fDrawTarget->drawBatch(pipelineBuilder, batch); 289 fDrawTarget->drawBatch(pipelineBuilder, batch);
290 return; 290 return;
291 } 291 }
292 292
293 if (width >= 0) { 293 if (width >= 0) {
294 // Non-AA hairlines are snapped to pixel centers to make which pixels ar e hit deterministic 294 // Non-AA hairlines are snapped to pixel centers to make which pixels ar e hit deterministic
295 bool snapToPixelCenters = (0 == width && !rt->isUnifiedMultisampled()); 295 bool snapToPixelCenters = (0 == width && !rt->isUnifiedMultisampled());
296 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateStrokeBW( 296 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAStroke(
297 color, viewMatrix, rect, width, snapToPi xelCenters)); 297 color, viewMatrix, rect, width, snapToPi xelCenters));
298 298
299 // Depending on sub-pixel coordinates and the particular GPU, we may los e a corner of 299 // Depending on sub-pixel coordinates and the particular GPU, we may los e a corner of
300 // hairline rects. We jam all the vertices to pixel centers to avoid thi s, but not when MSAA 300 // hairline rects. We jam all the vertices to pixel centers to avoid thi s, but not when MSAA
301 // is enabled because it can cause ugly artifacts. 301 // is enabled because it can cause ugly artifacts.
302 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_ Flag, 302 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_ Flag,
303 snapToPixelCenters); 303 snapToPixelCenters);
304 fDrawTarget->drawBatch(pipelineBuilder, batch); 304 fDrawTarget->drawBatch(pipelineBuilder, batch);
305 } else { 305 } else {
306 // filled BW rect 306 // filled BW rect
307 fDrawTarget->drawBWRect(pipelineBuilder, color, viewMatrix, rect); 307 fDrawTarget->drawNonAARect(pipelineBuilder, color, viewMatrix, rect);
308 } 308 }
309 } 309 }
310 310
311 void GrDrawContext::drawNonAARectToRect(GrRenderTarget* rt, 311 void GrDrawContext::drawNonAARectToRect(GrRenderTarget* rt,
312 const GrClip& clip, 312 const GrClip& clip,
313 const GrPaint& paint, 313 const GrPaint& paint,
314 const SkMatrix& viewMatrix, 314 const SkMatrix& viewMatrix,
315 const SkRect& rectToDraw, 315 const SkRect& rectToDraw,
316 const SkRect& localRect) { 316 const SkRect& localRect) {
317 RETURN_IF_ABANDONED 317 RETURN_IF_ABANDONED
318 AutoCheckFlush acf(fContext); 318 AutoCheckFlush acf(fContext);
319 if (!this->prepareToDraw(rt)) { 319 if (!this->prepareToDraw(rt)) {
320 return; 320 return;
321 } 321 }
322 322
323 GrPipelineBuilder pipelineBuilder(paint, rt, clip); 323 GrPipelineBuilder pipelineBuilder(paint, rt, clip);
324 fDrawTarget->drawBWRect(pipelineBuilder, 324 fDrawTarget->drawNonAARect(pipelineBuilder,
325 paint.getColor(), 325 paint.getColor(),
326 viewMatrix, 326 viewMatrix,
327 rectToDraw, 327 rectToDraw,
328 localRect); 328 localRect);
329 } 329 }
330 330
331 void GrDrawContext::drawNonAARectWithLocalMatrix(GrRenderTarget* rt, 331 void GrDrawContext::drawNonAARectWithLocalMatrix(GrRenderTarget* rt,
332 const GrClip& clip, 332 const GrClip& clip,
333 const GrPaint& paint, 333 const GrPaint& paint,
334 const SkMatrix& viewMatrix, 334 const SkMatrix& viewMatrix,
335 const SkRect& rectToDraw, 335 const SkRect& rectToDraw,
336 const SkMatrix& localMatrix) { 336 const SkMatrix& localMatrix) {
337 RETURN_IF_ABANDONED 337 RETURN_IF_ABANDONED
338 AutoCheckFlush acf(fContext); 338 AutoCheckFlush acf(fContext);
339 if (!this->prepareToDraw(rt)) { 339 if (!this->prepareToDraw(rt)) {
340 return; 340 return;
341 } 341 }
342 342
343 GrPipelineBuilder pipelineBuilder(paint, rt, clip); 343 GrPipelineBuilder pipelineBuilder(paint, rt, clip);
344 fDrawTarget->drawBWRect(pipelineBuilder, 344 fDrawTarget->drawNonAARect(pipelineBuilder,
345 paint.getColor(), 345 paint.getColor(),
346 viewMatrix, 346 viewMatrix,
347 rectToDraw, 347 rectToDraw,
348 localMatrix); 348 localMatrix);
349 } 349 }
350 350
351 void GrDrawContext::drawVertices(GrRenderTarget* rt, 351 void GrDrawContext::drawVertices(GrRenderTarget* rt,
352 const GrClip& clip, 352 const GrClip& clip,
353 const GrPaint& paint, 353 const GrPaint& paint,
354 const SkMatrix& viewMatrix, 354 const SkMatrix& viewMatrix,
355 GrPrimitiveType primitiveType, 355 GrPrimitiveType primitiveType,
356 int vertexCount, 356 int vertexCount,
357 const SkPoint positions[], 357 const SkPoint positions[],
358 const SkPoint texCoords[], 358 const SkPoint texCoords[],
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 GrPipelineBuilder pipelineBuilder(paint, rt, clip); 635 GrPipelineBuilder pipelineBuilder(paint, rt, clip);
636 if (!strokeInfo.isDashed()) { 636 if (!strokeInfo.isDashed()) {
637 bool useCoverageAA = paint.isAntiAlias() && 637 bool useCoverageAA = paint.isAntiAlias() &&
638 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); 638 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled();
639 639
640 if (useCoverageAA && strokeInfo.getWidth() < 0 && !path.isConvex()) { 640 if (useCoverageAA && strokeInfo.getWidth() < 0 && !path.isConvex()) {
641 // Concave AA paths are expensive - try to avoid them for special ca ses 641 // Concave AA paths are expensive - try to avoid them for special ca ses
642 SkRect rects[2]; 642 SkRect rects[2];
643 643
644 if (is_nested_rects(viewMatrix, path, strokeInfo, rects)) { 644 if (is_nested_rects(viewMatrix, path, strokeInfo, rects)) {
645 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateFillNe stedRectsAA( 645 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill NestedRects(
646 color, viewMatrix, rects)); 646 color, viewMatrix, rects));
647 fDrawTarget->drawBatch(pipelineBuilder, batch); 647 fDrawTarget->drawBatch(pipelineBuilder, batch);
648 return; 648 return;
649 } 649 }
650 } 650 }
651 SkRect ovalRect; 651 SkRect ovalRect;
652 bool isOval = path.isOval(&ovalRect); 652 bool isOval = path.isOval(&ovalRect);
653 653
654 if (isOval && !path.isInverseFillType()) { 654 if (isOval && !path.isInverseFillType()) {
655 if (GrOvalRenderer::DrawOval(fDrawTarget, 655 if (GrOvalRenderer::DrawOval(fDrawTarget,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 RETURN_FALSE_IF_ABANDONED 760 RETURN_FALSE_IF_ABANDONED
761 761
762 ASSERT_OWNED_RESOURCE(rt); 762 ASSERT_OWNED_RESOURCE(rt);
763 SkASSERT(rt); 763 SkASSERT(rt);
764 return true; 764 return true;
765 } 765 }
766 766
767 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 767 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) {
768 fDrawTarget->drawBatch(*pipelineBuilder, batch); 768 fDrawTarget->drawBatch(*pipelineBuilder, batch);
769 } 769 }
OLDNEW
« no previous file with comments | « src/gpu/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrDrawTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698