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

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

Issue 1842753002: Style bikeshed - remove extraneous whitespace (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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/GrContextFactory.cpp ('k') | src/gpu/GrDrawContextPriv.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
2 /* 1 /*
3 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
4 * 3 *
5 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9 #include "GrBatchTest.h" 8 #include "GrBatchTest.h"
10 #include "GrColor.h" 9 #include "GrColor.h"
11 #include "GrDrawContext.h" 10 #include "GrDrawContext.h"
(...skipping 24 matching lines...) Expand all
36 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);) 35 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);)
37 #define ASSERT_SINGLE_OWNER_PRIV \ 36 #define ASSERT_SINGLE_OWNER_PRIV \
38 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fDrawContext->fSing leOwner);) 37 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fDrawContext->fSing leOwner);)
39 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } 38 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; }
40 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa lse; } 39 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa lse; }
41 #define RETURN_FALSE_IF_ABANDONED_PRIV if (fDrawContext->fDrawingManager->aband oned()) { return false; } 40 #define RETURN_FALSE_IF_ABANDONED_PRIV if (fDrawContext->fDrawingManager->aband oned()) { return false; }
42 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nu llptr; } 41 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nu llptr; }
43 42
44 class AutoCheckFlush { 43 class AutoCheckFlush {
45 public: 44 public:
46 AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingMa nager) { 45 AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingMa nager) {
47 SkASSERT(fDrawingManager); 46 SkASSERT(fDrawingManager);
48 } 47 }
49 ~AutoCheckFlush() { fDrawingManager->getContext()->flushIfNecessary(); } 48 ~AutoCheckFlush() { fDrawingManager->getContext()->flushIfNecessary(); }
50 49
51 private: 50 private:
52 GrDrawingManager* fDrawingManager; 51 GrDrawingManager* fDrawingManager;
53 }; 52 };
54 53
55 // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-pr ogress 54 // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-pr ogress
56 // drawTargets to be picked up and added to by drawContexts lower in the call 55 // drawTargets to be picked up and added to by drawContexts lower in the call
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // The fill path can handle rotation but not skew. 262 // The fill path can handle rotation but not skew.
264 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { 263 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
265 SkRect devBoundRect; 264 SkRect devBoundRect;
266 viewMatrix.mapRect(&devBoundRect, rect); 265 viewMatrix.mapRect(&devBoundRect, rect);
267 batch = GrRectBatchFactory::CreateAAFill(paint.getColor(), viewMatri x, 266 batch = GrRectBatchFactory::CreateAAFill(paint.getColor(), viewMatri x,
268 rect, devBoundRect); 267 rect, devBoundRect);
269 } 268 }
270 } else { 269 } else {
271 // filled BW rect 270 // filled BW rect
272 batch = GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix , rect, 271 batch = GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix , rect,
273 nullptr, nullptr); 272 nullptr, nullptr);
274 } 273 }
275 274
276 return batch; 275 return batch;
277 } 276 }
278 277
279 void GrDrawContext::drawRect(const GrClip& clip, 278 void GrDrawContext::drawRect(const GrClip& clip,
280 const GrPaint& paint, 279 const GrPaint& paint,
281 const SkMatrix& viewMatrix, 280 const SkMatrix& viewMatrix,
282 const SkRect& rect, 281 const SkRect& rect,
283 const GrStrokeInfo* strokeInfo) { 282 const GrStrokeInfo* strokeInfo) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 *strokeInfo)); 340 *strokeInfo));
342 } 341 }
343 } else { 342 } else {
344 // Non-AA hairlines are snapped to pixel centers to make which pixel s are hit 343 // Non-AA hairlines are snapped to pixel centers to make which pixel s are hit
345 // deterministic 344 // deterministic
346 snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultisa mpled()); 345 snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultisa mpled());
347 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect, 346 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect,
348 width, snapToPixel Centers)); 347 width, snapToPixel Centers));
349 348
350 // Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of 349 // Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of
351 // hairline rects. We jam all the vertices to pixel centers to avoid this, but not 350 // hairline rects. We jam all the vertices to pixel centers to avoid this, but not
352 // when MSAA is enabled because it can cause ugly artifacts. 351 // when MSAA is enabled because it can cause ugly artifacts.
353 } 352 }
354 } 353 }
355 354
356 if (batch) { 355 if (batch) {
357 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 356 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
358 357
359 if (snapToPixelCenters) { 358 if (snapToPixelCenters) {
360 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent ers_Flag, 359 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent ers_Flag,
361 snapToPixelCenters); 360 snapToPixelCenters);
362 } 361 }
363 362
364 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 363 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
365 return; 364 return;
366 } 365 }
367 366
368 SkPath path; 367 SkPath path;
369 path.setIsVolatile(true); 368 path.setIsVolatile(true);
370 path.addRect(rect); 369 path.addRect(rect);
371 this->internalDrawPath(clip, paint, viewMatrix, path, 370 this->internalDrawPath(clip, paint, viewMatrix, path,
372 strokeInfo ? *strokeInfo : GrStrokeInfo::FillInfo()); 371 strokeInfo ? *strokeInfo : GrStrokeInfo::FillInfo());
373 } 372 }
374 373
375 bool GrDrawContextPriv::drawAndStencilRect(const SkIRect* scissorRect, 374 bool GrDrawContextPriv::drawAndStencilRect(const SkIRect* scissorRect,
376 const GrStencilSettings& ss, 375 const GrStencilSettings& ss,
377 SkRegion::Op op, 376 SkRegion::Op op,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 int spriteCount, 511 int spriteCount,
513 const SkRSXform xform[], 512 const SkRSXform xform[],
514 const SkRect texRect[], 513 const SkRect texRect[],
515 const SkColor colors[]) { 514 const SkColor colors[]) {
516 ASSERT_SINGLE_OWNER 515 ASSERT_SINGLE_OWNER
517 RETURN_IF_ABANDONED 516 RETURN_IF_ABANDONED
518 SkDEBUGCODE(this->validate();) 517 SkDEBUGCODE(this->validate();)
519 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas"); 518 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas");
520 519
521 AutoCheckFlush acf(fDrawingManager); 520 AutoCheckFlush acf(fDrawingManager);
522 521
523 GrDrawAtlasBatch::Geometry geometry; 522 GrDrawAtlasBatch::Geometry geometry;
524 geometry.fColor = paint.getColor(); 523 geometry.fColor = paint.getColor();
525 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri x, spriteCount, 524 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri x, spriteCount,
526 xform, texRect, col ors)); 525 xform, texRect, col ors));
527 526
528 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 527 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
529 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 528 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
530 } 529 }
531 530
532 /////////////////////////////////////////////////////////////////////////////// 531 ///////////////////////////////////////////////////////////////////////////////
533 532
534 void GrDrawContext::drawRRect(const GrClip& clip, 533 void GrDrawContext::drawRRect(const GrClip& clip,
535 const GrPaint& paint, 534 const GrPaint& paint,
536 const SkMatrix& viewMatrix, 535 const SkMatrix& viewMatrix,
537 const SkRRect& rrect, 536 const SkRRect& rrect,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 return false; 591 return false;
593 } 592 }
594 if (!origOuter.transform(viewMatrix, outer.writable())) { 593 if (!origOuter.transform(viewMatrix, outer.writable())) {
595 return false; 594 return false;
596 } 595 }
597 if (!viewMatrix.invert(&inverseVM)) { 596 if (!viewMatrix.invert(&inverseVM)) {
598 return false; 597 return false;
599 } 598 }
600 } else { 599 } else {
601 inverseVM.reset(); 600 inverseVM.reset();
602 } 601 }
603 602
604 GrPaint grPaint(paintIn); 603 GrPaint grPaint(paintIn);
605 grPaint.setAntiAlias(false); 604 grPaint.setAntiAlias(false);
606 605
607 // TODO these need to be a geometry processors 606 // TODO these need to be a geometry processors
608 SkAutoTUnref<GrFragmentProcessor> innerEffect(GrRRectEffect::Create(innerEdg eType, *inner)); 607 SkAutoTUnref<GrFragmentProcessor> innerEffect(GrRRectEffect::Create(innerEdg eType, *inner));
609 if (!innerEffect) { 608 if (!innerEffect) {
610 return false; 609 return false;
611 } 610 }
612 611
613 SkAutoTUnref<GrFragmentProcessor> outerEffect(GrRRectEffect::Create(outerEdg eType, *outer)); 612 SkAutoTUnref<GrFragmentProcessor> outerEffect(GrRRectEffect::Create(outerEdg eType, *outer));
614 if (!outerEffect) { 613 if (!outerEffect) {
615 return false; 614 return false;
616 } 615 }
617 616
618 grPaint.addCoverageFragmentProcessor(innerEffect); 617 grPaint.addCoverageFragmentProcessor(innerEffect);
619 grPaint.addCoverageFragmentProcessor(outerEffect); 618 grPaint.addCoverageFragmentProcessor(outerEffect);
620 619
621 SkRect bounds = outer->getBounds(); 620 SkRect bounds = outer->getBounds();
622 if (applyAA) { 621 if (applyAA) {
623 bounds.outset(SK_ScalarHalf, SK_ScalarHalf); 622 bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
624 } 623 }
625 624
626 this->fillRectWithLocalMatrix(clip, grPaint, SkMatrix::I(), bounds, inverseV M); 625 this->fillRectWithLocalMatrix(clip, grPaint, SkMatrix::I(), bounds, inverseV M);
627 return true; 626 return true;
628 } 627 }
629 628
630 void GrDrawContext::drawDRRect(const GrClip& clip, 629 void GrDrawContext::drawDRRect(const GrClip& clip,
631 const GrPaint& paint, 630 const GrPaint& paint,
632 const SkMatrix& viewMatrix, 631 const SkMatrix& viewMatrix,
633 const SkRRect& outer, 632 const SkRRect& outer,
634 const SkRRect& inner) { 633 const SkRRect& inner) {
635 ASSERT_SINGLE_OWNER 634 ASSERT_SINGLE_OWNER
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 bool invert, 858 bool invert,
860 bool doAA, 859 bool doAA,
861 const SkMatrix& viewMatrix, 860 const SkMatrix& viewMatrix,
862 const SkPath& path) { 861 const SkPath& path) {
863 ASSERT_SINGLE_OWNER_PRIV 862 ASSERT_SINGLE_OWNER_PRIV
864 RETURN_FALSE_IF_ABANDONED_PRIV 863 RETURN_FALSE_IF_ABANDONED_PRIV
865 SkDEBUGCODE(fDrawContext->validate();) 864 SkDEBUGCODE(fDrawContext->validate();)
866 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPat h"); 865 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPat h");
867 866
868 if (path.isEmpty() && path.isInverseFillType()) { 867 if (path.isEmpty() && path.isInverseFillType()) {
869 this->drawAndStencilRect(scissorRect, ss, op, invert, false, SkMatrix::I (), 868 this->drawAndStencilRect(scissorRect, ss, op, invert, false, SkMatrix::I (),
870 SkRect::MakeIWH(fDrawContext->fRenderTarget->wi dth(), 869 SkRect::MakeIWH(fDrawContext->fRenderTarget->wi dth(),
871 fDrawContext->fRenderTarget->he ight())); 870 fDrawContext->fRenderTarget->he ight()));
872 return true; 871 return true;
873 } 872 }
874 873
875 AutoCheckFlush acf(fDrawContext->fDrawingManager); 874 AutoCheckFlush acf(fDrawContext->fDrawingManager);
876 875
877 // An Assumption here is that path renderer would use some form of tweaking 876 // An Assumption here is that path renderer would use some form of tweaking
878 // the src color (either the input alpha or in the frag shader) to implement 877 // the src color (either the input alpha or in the frag shader) to implement
879 // aa. If we have some future driver-mojo path AA that can do the right 878 // aa. If we have some future driver-mojo path AA that can do the right
880 // thing WRT to the blend then we'll need some query on the PR. 879 // thing WRT to the blend then we'll need some query on the PR.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 } 1029 }
1031 1030
1032 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 1031 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) {
1033 ASSERT_SINGLE_OWNER 1032 ASSERT_SINGLE_OWNER
1034 RETURN_IF_ABANDONED 1033 RETURN_IF_ABANDONED
1035 SkDEBUGCODE(this->validate();) 1034 SkDEBUGCODE(this->validate();)
1036 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); 1035 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch");
1037 1036
1038 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); 1037 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch);
1039 } 1038 }
OLDNEW
« no previous file with comments | « src/gpu/GrContextFactory.cpp ('k') | src/gpu/GrDrawContextPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698