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

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

Issue 1385233002: Move scissor state to GrAppliedClip (Closed) Base URL: https://skia.googlesource.com/skia.git@enum
Patch Set: revert accidental whitespace change Created 5 years, 2 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 #include "GrClipMaskManager.h" 8 #include "GrClipMaskManager.h"
9 #include "GrCaps.h" 9 #include "GrCaps.h"
10 #include "GrDrawContext.h" 10 #include "GrDrawContext.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 fps[i]->unref(); 196 fps[i]->unref();
197 } 197 }
198 return resultFP; 198 return resultFP;
199 } 199 }
200 200
201 //////////////////////////////////////////////////////////////////////////////// 201 ////////////////////////////////////////////////////////////////////////////////
202 // sort out what kind of clip mask needs to be created: alpha, stencil, 202 // sort out what kind of clip mask needs to be created: alpha, stencil,
203 // scissor, or entirely software 203 // scissor, or entirely software
204 bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder, 204 bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
205 GrPipelineBuilder::AutoRestoreStencil* ars , 205 GrPipelineBuilder::AutoRestoreStencil* ars ,
206 GrScissorState* scissorState,
207 const SkRect* devBounds, 206 const SkRect* devBounds,
208 GrAppliedClip* out) { 207 GrAppliedClip* out) {
209 if (kRespectClip_StencilClipMode == fClipMode) { 208 if (kRespectClip_StencilClipMode == fClipMode) {
210 fClipMode = kIgnoreClip_StencilClipMode; 209 fClipMode = kIgnoreClip_StencilClipMode;
211 } 210 }
212 211
213 GrReducedClip::ElementList elements(16); 212 GrReducedClip::ElementList elements(16);
214 int32_t genID = 0; 213 int32_t genID = 0;
215 GrReducedClip::InitialState initialState = GrReducedClip::kAllIn_InitialStat e; 214 GrReducedClip::InitialState initialState = GrReducedClip::kAllIn_InitialStat e;
216 SkIRect clipSpaceIBounds; 215 SkIRect clipSpaceIBounds;
(...skipping 12 matching lines...) Expand all
229 228
230 // The clip mask manager always draws with a single IRect so we special case that logic here 229 // The clip mask manager always draws with a single IRect so we special case that logic here
231 // Image filters just use a rect, so we also special case that logic 230 // Image filters just use a rect, so we also special case that logic
232 switch (clip.clipType()) { 231 switch (clip.clipType()) {
233 case GrClip::kWideOpen_ClipType: 232 case GrClip::kWideOpen_ClipType:
234 SkFAIL("Should have caught this with clip.isWideOpen()"); 233 SkFAIL("Should have caught this with clip.isWideOpen()");
235 return true; 234 return true;
236 case GrClip::kIRect_ClipType: { 235 case GrClip::kIRect_ClipType: {
237 SkIRect scissor = clip.irect(); 236 SkIRect scissor = clip.irect();
238 if (scissor.intersect(clipSpaceRTIBounds)) { 237 if (scissor.intersect(clipSpaceRTIBounds)) {
239 scissorState->set(scissor); 238 out->fScissorState.set(scissor);
240 this->setPipelineBuilderStencil(pipelineBuilder, ars); 239 this->setPipelineBuilderStencil(pipelineBuilder, ars);
241 return true; 240 return true;
242 } 241 }
243 return false; 242 return false;
244 } 243 }
245 case GrClip::kClipStack_ClipType: { 244 case GrClip::kClipStack_ClipType: {
246 clipSpaceRTIBounds.offset(clip.origin()); 245 clipSpaceRTIBounds.offset(clip.origin());
247 GrReducedClip::ReduceClipStack(*clip.clipStack(), 246 GrReducedClip::ReduceClipStack(*clip.clipStack(),
248 clipSpaceRTIBounds, 247 clipSpaceRTIBounds,
249 &elements, 248 &elements,
(...skipping 29 matching lines...) Expand all
279 // a fractional pixel coverage. 278 // a fractional pixel coverage.
280 bool disallowAnalyticAA = pipelineBuilder.getRenderTarget()->isUnifiedMu ltisampled(); 279 bool disallowAnalyticAA = pipelineBuilder.getRenderTarget()->isUnifiedMu ltisampled();
281 const GrFragmentProcessor* clipFP = nullptr; 280 const GrFragmentProcessor* clipFP = nullptr;
282 if (elements.isEmpty() || 281 if (elements.isEmpty() ||
283 (requiresAA && !disallowAnalyticAA && 282 (requiresAA && !disallowAnalyticAA &&
284 SkToBool(clipFP = this->getAnalyticClipProcessor(elements, clipToRT Offset, devBounds)))) { 283 SkToBool(clipFP = this->getAnalyticClipProcessor(elements, clipToRT Offset, devBounds)))) {
285 SkIRect scissorSpaceIBounds(clipSpaceIBounds); 284 SkIRect scissorSpaceIBounds(clipSpaceIBounds);
286 scissorSpaceIBounds.offset(-clip.origin()); 285 scissorSpaceIBounds.offset(-clip.origin());
287 if (nullptr == devBounds || 286 if (nullptr == devBounds ||
288 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) { 287 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) {
289 scissorState->set(scissorSpaceIBounds); 288 out->fScissorState.set(scissorSpaceIBounds);
290 } 289 }
291 this->setPipelineBuilderStencil(pipelineBuilder, ars); 290 this->setPipelineBuilderStencil(pipelineBuilder, ars);
292 out->fClipCoverageFP.reset(clipFP); 291 out->fClipCoverageFP.reset(clipFP);
293 return true; 292 return true;
294 } 293 }
295 } 294 }
296 295
297 // If MSAA is enabled we can do everything in the stencil buffer. 296 // If MSAA is enabled we can do everything in the stencil buffer.
298 if (0 == rt->numStencilSamples() && requiresAA) { 297 if (0 == rt->numStencilSamples() && requiresAA) {
299 SkAutoTUnref<GrTexture> result; 298 SkAutoTUnref<GrTexture> result;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 initialState, 338 initialState,
340 elements, 339 elements,
341 clipSpaceIBounds, 340 clipSpaceIBounds,
342 clipSpaceToStencilSpaceOffset); 341 clipSpaceToStencilSpaceOffset);
343 342
344 // This must occur after createStencilClipMask. That function may change the scissor. Also, it 343 // This must occur after createStencilClipMask. That function may change the scissor. Also, it
345 // only guarantees that the stencil mask is correct within the bounds it was passed, so we must 344 // only guarantees that the stencil mask is correct within the bounds it was passed, so we must
346 // use both stencil and scissor test to the bounds for the final draw. 345 // use both stencil and scissor test to the bounds for the final draw.
347 SkIRect scissorSpaceIBounds(clipSpaceIBounds); 346 SkIRect scissorSpaceIBounds(clipSpaceIBounds);
348 scissorSpaceIBounds.offset(clipSpaceToStencilSpaceOffset); 347 scissorSpaceIBounds.offset(clipSpaceToStencilSpaceOffset);
349 scissorState->set(scissorSpaceIBounds); 348 out->fScissorState.set(scissorSpaceIBounds);
350 this->setPipelineBuilderStencil(pipelineBuilder, ars); 349 this->setPipelineBuilderStencil(pipelineBuilder, ars);
351 return true; 350 return true;
352 } 351 }
353 352
354 namespace { 353 namespace {
355 //////////////////////////////////////////////////////////////////////////////// 354 ////////////////////////////////////////////////////////////////////////////////
356 // Set a coverage drawing XPF on the pipelineBuilder for the given op and invert Coverage mode 355 // Set a coverage drawing XPF on the pipelineBuilder for the given op and invert Coverage mode
357 void set_coverage_drawing_xpf(SkRegion::Op op, bool invertCoverage, 356 void set_coverage_drawing_xpf(SkRegion::Op op, bool invertCoverage,
358 GrPipelineBuilder* pipelineBuilder) { 357 GrPipelineBuilder* pipelineBuilder) {
359 SkASSERT(op <= SkRegion::kLastOp); 358 SkASSERT(op <= SkRegion::kLastOp);
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 1108
1110 //////////////////////////////////////////////////////////////////////////////// 1109 ////////////////////////////////////////////////////////////////////////////////
1111 1110
1112 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc ilAttachment, 1111 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc ilAttachment,
1113 GrStencilSettings* settings) { 1112 GrStencilSettings* settings) {
1114 if (stencilAttachment) { 1113 if (stencilAttachment) {
1115 int stencilBits = stencilAttachment->bits(); 1114 int stencilBits = stencilAttachment->bits();
1116 this->adjustStencilParams(settings, fClipMode, stencilBits); 1115 this->adjustStencilParams(settings, fClipMode, stencilBits);
1117 } 1116 }
1118 } 1117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698