| OLD | NEW |
| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 fps[i]->unref(); | 202 fps[i]->unref(); |
| 203 } | 203 } |
| 204 return !failed; | 204 return !failed; |
| 205 } | 205 } |
| 206 | 206 |
| 207 //////////////////////////////////////////////////////////////////////////////// | 207 //////////////////////////////////////////////////////////////////////////////// |
| 208 // sort out what kind of clip mask needs to be created: alpha, stencil, | 208 // sort out what kind of clip mask needs to be created: alpha, stencil, |
| 209 // scissor, or entirely software | 209 // scissor, or entirely software |
| 210 bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder, | 210 bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder, |
| 211 GrPipelineBuilder::AutoRestoreStencil* ars
, | 211 GrPipelineBuilder::AutoRestoreStencil* ars
, |
| 212 GrScissorState* scissorState, | |
| 213 const SkRect* devBounds, | 212 const SkRect* devBounds, |
| 214 GrAppliedClip* out) { | 213 GrAppliedClip* out) { |
| 215 if (kRespectClip_StencilClipMode == fClipMode) { | 214 if (kRespectClip_StencilClipMode == fClipMode) { |
| 216 fClipMode = kIgnoreClip_StencilClipMode; | 215 fClipMode = kIgnoreClip_StencilClipMode; |
| 217 } | 216 } |
| 218 | 217 |
| 219 GrReducedClip::ElementList elements(16); | 218 GrReducedClip::ElementList elements(16); |
| 220 int32_t genID = 0; | 219 int32_t genID = 0; |
| 221 GrReducedClip::InitialState initialState = GrReducedClip::kAllIn_InitialStat
e; | 220 GrReducedClip::InitialState initialState = GrReducedClip::kAllIn_InitialStat
e; |
| 222 SkIRect clipSpaceIBounds; | 221 SkIRect clipSpaceIBounds; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 235 | 234 |
| 236 // The clip mask manager always draws with a single IRect so we special case
that logic here | 235 // The clip mask manager always draws with a single IRect so we special case
that logic here |
| 237 // Image filters just use a rect, so we also special case that logic | 236 // Image filters just use a rect, so we also special case that logic |
| 238 switch (clip.clipType()) { | 237 switch (clip.clipType()) { |
| 239 case GrClip::kWideOpen_ClipType: | 238 case GrClip::kWideOpen_ClipType: |
| 240 SkFAIL("Should have caught this with clip.isWideOpen()"); | 239 SkFAIL("Should have caught this with clip.isWideOpen()"); |
| 241 return true; | 240 return true; |
| 242 case GrClip::kIRect_ClipType: { | 241 case GrClip::kIRect_ClipType: { |
| 243 SkIRect scissor = clip.irect(); | 242 SkIRect scissor = clip.irect(); |
| 244 if (scissor.intersect(clipSpaceRTIBounds)) { | 243 if (scissor.intersect(clipSpaceRTIBounds)) { |
| 245 scissorState->set(scissor); | 244 out->fScissorState.set(scissor); |
| 246 this->setPipelineBuilderStencil(pipelineBuilder, ars); | 245 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
| 247 return true; | 246 return true; |
| 248 } | 247 } |
| 249 return false; | 248 return false; |
| 250 } | 249 } |
| 251 case GrClip::kClipStack_ClipType: { | 250 case GrClip::kClipStack_ClipType: { |
| 252 clipSpaceRTIBounds.offset(clip.origin()); | 251 clipSpaceRTIBounds.offset(clip.origin()); |
| 253 GrReducedClip::ReduceClipStack(*clip.clipStack(), | 252 GrReducedClip::ReduceClipStack(*clip.clipStack(), |
| 254 clipSpaceRTIBounds, | 253 clipSpaceRTIBounds, |
| 255 &elements, | 254 &elements, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 286 bool disallowAnalyticAA = pipelineBuilder.getRenderTarget()->isUnifiedMu
ltisampled(); | 285 bool disallowAnalyticAA = pipelineBuilder.getRenderTarget()->isUnifiedMu
ltisampled(); |
| 287 const GrFragmentProcessor* clipFP = nullptr; | 286 const GrFragmentProcessor* clipFP = nullptr; |
| 288 if (elements.isEmpty() || | 287 if (elements.isEmpty() || |
| 289 (requiresAA && | 288 (requiresAA && |
| 290 this->getAnalyticClipProcessor(elements, disallowAnalyticAA, clipTo
RTOffset, devBounds, | 289 this->getAnalyticClipProcessor(elements, disallowAnalyticAA, clipTo
RTOffset, devBounds, |
| 291 &clipFP))) { | 290 &clipFP))) { |
| 292 SkIRect scissorSpaceIBounds(clipSpaceIBounds); | 291 SkIRect scissorSpaceIBounds(clipSpaceIBounds); |
| 293 scissorSpaceIBounds.offset(-clip.origin()); | 292 scissorSpaceIBounds.offset(-clip.origin()); |
| 294 if (nullptr == devBounds || | 293 if (nullptr == devBounds || |
| 295 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) { | 294 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) { |
| 296 scissorState->set(scissorSpaceIBounds); | 295 out->fScissorState.set(scissorSpaceIBounds); |
| 297 } | 296 } |
| 298 this->setPipelineBuilderStencil(pipelineBuilder, ars); | 297 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
| 299 out->fClipCoverageFP.reset(clipFP); | 298 out->fClipCoverageFP.reset(clipFP); |
| 300 return true; | 299 return true; |
| 301 } | 300 } |
| 302 } | 301 } |
| 303 | 302 |
| 304 // If MSAA is enabled we can do everything in the stencil buffer. | 303 // If MSAA is enabled we can do everything in the stencil buffer. |
| 305 if (0 == rt->numStencilSamples() && requiresAA) { | 304 if (0 == rt->numStencilSamples() && requiresAA) { |
| 306 SkAutoTUnref<GrTexture> result; | 305 SkAutoTUnref<GrTexture> result; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 initialState, | 345 initialState, |
| 347 elements, | 346 elements, |
| 348 clipSpaceIBounds, | 347 clipSpaceIBounds, |
| 349 clipSpaceToStencilSpaceOffset); | 348 clipSpaceToStencilSpaceOffset); |
| 350 | 349 |
| 351 // This must occur after createStencilClipMask. That function may change the
scissor. Also, it | 350 // This must occur after createStencilClipMask. That function may change the
scissor. Also, it |
| 352 // only guarantees that the stencil mask is correct within the bounds it was
passed, so we must | 351 // only guarantees that the stencil mask is correct within the bounds it was
passed, so we must |
| 353 // use both stencil and scissor test to the bounds for the final draw. | 352 // use both stencil and scissor test to the bounds for the final draw. |
| 354 SkIRect scissorSpaceIBounds(clipSpaceIBounds); | 353 SkIRect scissorSpaceIBounds(clipSpaceIBounds); |
| 355 scissorSpaceIBounds.offset(clipSpaceToStencilSpaceOffset); | 354 scissorSpaceIBounds.offset(clipSpaceToStencilSpaceOffset); |
| 356 scissorState->set(scissorSpaceIBounds); | 355 out->fScissorState.set(scissorSpaceIBounds); |
| 357 this->setPipelineBuilderStencil(pipelineBuilder, ars); | 356 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
| 358 return true; | 357 return true; |
| 359 } | 358 } |
| 360 | 359 |
| 361 namespace { | 360 namespace { |
| 362 //////////////////////////////////////////////////////////////////////////////// | 361 //////////////////////////////////////////////////////////////////////////////// |
| 363 // Set a coverage drawing XPF on the pipelineBuilder for the given op and invert
Coverage mode | 362 // Set a coverage drawing XPF on the pipelineBuilder for the given op and invert
Coverage mode |
| 364 void set_coverage_drawing_xpf(SkRegion::Op op, bool invertCoverage, | 363 void set_coverage_drawing_xpf(SkRegion::Op op, bool invertCoverage, |
| 365 GrPipelineBuilder* pipelineBuilder) { | 364 GrPipelineBuilder* pipelineBuilder) { |
| 366 SkASSERT(op <= SkRegion::kLastOp); | 365 SkASSERT(op <= SkRegion::kLastOp); |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 | 1113 |
| 1115 //////////////////////////////////////////////////////////////////////////////// | 1114 //////////////////////////////////////////////////////////////////////////////// |
| 1116 | 1115 |
| 1117 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, | 1116 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, |
| 1118 GrStencilSettings* settings) { | 1117 GrStencilSettings* settings) { |
| 1119 if (stencilAttachment) { | 1118 if (stencilAttachment) { |
| 1120 int stencilBits = stencilAttachment->bits(); | 1119 int stencilBits = stencilAttachment->bits(); |
| 1121 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1120 this->adjustStencilParams(settings, fClipMode, stencilBits); |
| 1122 } | 1121 } |
| 1123 } | 1122 } |
| OLD | NEW |