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

Side by Side Diff: src/gpu/batches/GrStencilAndCoverPathRenderer.cpp

Issue 1966903004: Remove clip from GrPipelineBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@fix2_nvpr
Patch Set: Created 4 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * 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
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "GrStencilAndCoverPathRenderer.h" 9 #include "GrStencilAndCoverPathRenderer.h"
10 #include "GrCaps.h" 10 #include "GrCaps.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 SkASSERT(path->isEqualTo(skPath, style)); 62 SkASSERT(path->isEqualTo(skPath, style));
63 } 63 }
64 return path.release(); 64 return path.release();
65 } 65 }
66 66
67 void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) { 67 void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) {
68 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), 68 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(),
69 "GrStencilAndCoverPathRenderer::onStencilPath"); 69 "GrStencilAndCoverPathRenderer::onStencilPath");
70 SkASSERT(!args.fPath->isInverseFillType()); 70 SkASSERT(!args.fPath->isInverseFillType());
71 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, *args.fPath, GrStyle:: SimpleFill())); 71 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, *args.fPath, GrStyle:: SimpleFill()));
72 args.fTarget->stencilPath(*args.fPipelineBuilder, *args.fViewMatrix, p, p->g etFillType()); 72 args.fTarget->stencilPath(*args.fPipelineBuilder, *args.fClip, *args.fViewMa trix, p,
73 p->getFillType());
73 } 74 }
74 75
75 bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { 76 bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
76 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), 77 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(),
77 "GrStencilAndCoverPathRenderer::onDrawPath"); 78 "GrStencilAndCoverPathRenderer::onDrawPath");
78 SkASSERT(!args.fStyle->strokeRec().isHairlineStyle()); 79 SkASSERT(!args.fStyle->strokeRec().isHairlineStyle());
79 const SkPath& path = *args.fPath; 80 const SkPath& path = *args.fPath;
80 GrPipelineBuilder* pipelineBuilder = args.fPipelineBuilder; 81 GrPipelineBuilder* pipelineBuilder = args.fPipelineBuilder;
81 const SkMatrix& viewMatrix = *args.fViewMatrix; 82 const SkMatrix& viewMatrix = *args.fViewMatrix;
82 83
(...skipping 17 matching lines...) Expand all
100 0xffff, 101 0xffff,
101 GrUserStencilOp::kKeep, 102 GrUserStencilOp::kKeep,
102 GrUserStencilOp::kZero, 103 GrUserStencilOp::kZero,
103 0xffff>() 104 0xffff>()
104 ); 105 );
105 106
106 107
107 pipelineBuilder->setUserStencil(&kInvertedCoverPass); 108 pipelineBuilder->setUserStencil(&kInvertedCoverPass);
108 109
109 // fake inverse with a stencil and cover 110 // fake inverse with a stencil and cover
110 args.fTarget->stencilPath(*pipelineBuilder, viewMatrix, p, p->getFillTyp e()); 111 args.fTarget->stencilPath(*pipelineBuilder, *args.fClip, viewMatrix, p, p->getFillType());
111 112
112 SkMatrix invert = SkMatrix::I(); 113 SkMatrix invert = SkMatrix::I();
113 SkRect bounds = 114 SkRect bounds =
114 SkRect::MakeLTRB(0, 0, SkIntToScalar(pipelineBuilder->getRenderTarge t()->width()), 115 SkRect::MakeLTRB(0, 0, SkIntToScalar(pipelineBuilder->getRenderTarge t()->width()),
115 SkIntToScalar(pipelineBuilder->getRenderTarget()->h eight())); 116 SkIntToScalar(pipelineBuilder->getRenderTarget()->h eight()));
116 SkMatrix vmi; 117 SkMatrix vmi;
117 // mapRect through persp matrix may not be correct 118 // mapRect through persp matrix may not be correct
118 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) { 119 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) {
119 vmi.mapRect(&bounds); 120 vmi.mapRect(&bounds);
120 // theoretically could set bloat = 0, instead leave it because of ma trix inversion 121 // theoretically could set bloat = 0, instead leave it because of ma trix inversion
121 // precision. 122 // precision.
122 SkScalar bloat = viewMatrix.getMaxScale() * SK_ScalarHalf; 123 SkScalar bloat = viewMatrix.getMaxScale() * SK_ScalarHalf;
123 bounds.outset(bloat, bloat); 124 bounds.outset(bloat, bloat);
124 } else { 125 } else {
125 if (!viewMatrix.invert(&invert)) { 126 if (!viewMatrix.invert(&invert)) {
126 return false; 127 return false;
127 } 128 }
128 } 129 }
129 const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : vi ewMatrix; 130 const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : vi ewMatrix;
130 if (pipelineBuilder->getRenderTarget()->hasMixedSamples()) { 131 if (pipelineBuilder->getRenderTarget()->hasMixedSamples()) {
131 pipelineBuilder->disableState(GrPipelineBuilder::kHWAntialias_Flag); 132 pipelineBuilder->disableState(GrPipelineBuilder::kHWAntialias_Flag);
132 } 133 }
133 134
134 SkAutoTUnref<GrDrawBatch> batch( 135 SkAutoTUnref<GrDrawBatch> batch(
135 GrRectBatchFactory::CreateNonAAFill(args.fColor, viewM, bounds, nullptr, 136 GrRectBatchFactory::CreateNonAAFill(args.fColor, viewM, bounds, nullptr,
136 &invert)); 137 &invert));
137 args.fTarget->drawBatch(*pipelineBuilder, batch); 138 args.fTarget->drawBatch(*pipelineBuilder, *args.fClip, batch);
138 } else { 139 } else {
139 static constexpr GrUserStencilSettings kCoverPass( 140 static constexpr GrUserStencilSettings kCoverPass(
140 GrUserStencilSettings::StaticInit< 141 GrUserStencilSettings::StaticInit<
141 0x0000, 142 0x0000,
142 GrUserStencilTest::kNotEqual, 143 GrUserStencilTest::kNotEqual,
143 0xffff, 144 0xffff,
144 GrUserStencilOp::kZero, 145 GrUserStencilOp::kZero,
145 GrUserStencilOp::kKeep, 146 GrUserStencilOp::kKeep,
146 0xffff>() 147 0xffff>()
147 ); 148 );
148 149
149 pipelineBuilder->setUserStencil(&kCoverPass); 150 pipelineBuilder->setUserStencil(&kCoverPass);
150 SkAutoTUnref<GrDrawBatch> batch( 151 SkAutoTUnref<GrDrawBatch> batch(
151 GrDrawPathBatch::Create(viewMatrix, args.fColor, p->getFillType( ), p)); 152 GrDrawPathBatch::Create(viewMatrix, args.fColor, p->getFillType( ), p));
152 args.fTarget->drawBatch(*pipelineBuilder, batch); 153 args.fTarget->drawBatch(*pipelineBuilder, *args.fClip, batch);
153 } 154 }
154 155
155 pipelineBuilder->disableUserStencil(); 156 pipelineBuilder->disableUserStencil();
156 return true; 157 return true;
157 } 158 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698