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 "GrDrawingManager.h" | 10 #include "GrDrawingManager.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 PathNeedsSWRenderer(context, | 119 PathNeedsSWRenderer(context, |
120 kStencilIsDisabled, | 120 kStencilIsDisabled, |
121 texture->asRenderTarget(), | 121 texture->asRenderTarget(), |
122 viewMatrix, | 122 viewMatrix, |
123 element, | 123 element, |
124 &pr, | 124 &pr, |
125 kNeedsStencil); | 125 kNeedsStencil); |
126 return pr; | 126 return pr; |
127 } | 127 } |
128 | 128 |
129 GrClipMaskManager::GrClipMaskManager(GrDrawTarget* drawTarget) | 129 GrClipMaskManager::GrClipMaskManager(GrDrawTarget* drawTarget, bool debugClipBat chToBounds) |
130 : fDrawTarget(drawTarget) | 130 : fDrawTarget(drawTarget) |
131 , fClipMode(kIgnoreClip_StencilClipMode) { | 131 , fClipMode(kIgnoreClip_StencilClipMode) |
132 , fDebugClipBatchToBounds(debugClipBatchToBounds) { | |
132 } | 133 } |
133 | 134 |
134 GrContext* GrClipMaskManager::getContext() { | 135 GrContext* GrClipMaskManager::getContext() { |
135 return fDrawTarget->cmmAccess().context(); | 136 return fDrawTarget->cmmAccess().context(); |
136 } | 137 } |
137 | 138 |
138 const GrCaps* GrClipMaskManager::caps() const { | 139 const GrCaps* GrClipMaskManager::caps() const { |
139 return fDrawTarget->caps(); | 140 return fDrawTarget->caps(); |
140 } | 141 } |
141 | 142 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 *resultFP = nullptr; | 266 *resultFP = nullptr; |
266 if (!failed && fpCnt) { | 267 if (!failed && fpCnt) { |
267 *resultFP = GrFragmentProcessor::RunInSeries(fps, fpCnt); | 268 *resultFP = GrFragmentProcessor::RunInSeries(fps, fpCnt); |
268 } | 269 } |
269 for (int i = 0; i < fpCnt; ++i) { | 270 for (int i = 0; i < fpCnt; ++i) { |
270 fps[i]->unref(); | 271 fps[i]->unref(); |
271 } | 272 } |
272 return !failed; | 273 return !failed; |
273 } | 274 } |
274 | 275 |
276 static void add_rect_to_clip(const GrClip& clip, const SkRect& devRect, GrClip* out) { | |
277 switch (clip.clipType()) { | |
278 case GrClip::kClipStack_ClipType: { | |
279 SkClipStack* stack = new SkClipStack; | |
280 *stack = *clip.clipStack(); | |
281 // The stack is actually in clip space not device space. | |
282 SkRect clipRect = devRect; | |
283 SkPoint origin = { SkIntToScalar(clip.origin().fX), SkIntToScalar(cl ip.origin().fY) }; | |
284 clipRect.offset(origin); | |
285 SkIRect iclipRect; | |
286 clipRect.roundOut(&iclipRect); | |
287 clipRect = SkRect::Make(iclipRect); | |
288 stack->clipDevRect(clipRect, SkRegion::kIntersect_Op, false); | |
289 out->setClipStack(stack, &clip.origin()); | |
290 break; | |
291 } | |
292 case GrClip::kWideOpen_ClipType: | |
293 *out = GrClip(devRect); | |
294 break; | |
295 case GrClip::kIRect_ClipType: | |
296 SkIRect intersect; | |
joshualitt
2015/11/23 20:48:28
braces
| |
297 devRect.roundOut(&intersect); | |
298 if (intersect.intersect(clip.irect())) { | |
299 *out = GrClip(intersect); | |
300 } else { | |
301 *out = clip; | |
302 } | |
303 break; | |
304 } | |
305 } | |
306 | |
275 //////////////////////////////////////////////////////////////////////////////// | 307 //////////////////////////////////////////////////////////////////////////////// |
276 // sort out what kind of clip mask needs to be created: alpha, stencil, | 308 // sort out what kind of clip mask needs to be created: alpha, stencil, |
277 // scissor, or entirely software | 309 // scissor, or entirely software |
278 bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder, | 310 bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder, |
279 GrPipelineBuilder::AutoRestoreStencil* ars , | 311 GrPipelineBuilder::AutoRestoreStencil* ars , |
280 const SkRect* devBounds, | 312 const SkRect* devBounds, |
281 GrAppliedClip* out) { | 313 GrAppliedClip* out) { |
282 if (kRespectClip_StencilClipMode == fClipMode) { | 314 if (kRespectClip_StencilClipMode == fClipMode) { |
283 fClipMode = kIgnoreClip_StencilClipMode; | 315 fClipMode = kIgnoreClip_StencilClipMode; |
284 } | 316 } |
285 | 317 |
286 GrReducedClip::ElementList elements; | 318 GrReducedClip::ElementList elements; |
287 int32_t genID = 0; | 319 int32_t genID = 0; |
288 GrReducedClip::InitialState initialState = GrReducedClip::kAllIn_InitialStat e; | 320 GrReducedClip::InitialState initialState = GrReducedClip::kAllIn_InitialStat e; |
289 SkIRect clipSpaceIBounds; | 321 SkIRect clipSpaceIBounds; |
290 bool requiresAA = false; | 322 bool requiresAA = false; |
291 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 323 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
292 | 324 |
293 // GrDrawTarget should have filtered this for us | 325 // GrDrawTarget should have filtered this for us |
294 SkASSERT(rt); | 326 SkASSERT(rt); |
295 | 327 |
296 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); | 328 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); |
297 const GrClip& clip = pipelineBuilder.clip(); | 329 GrClip devBoundsClip; |
330 bool doDevBoundsClip = fDebugClipBatchToBounds && devBounds; | |
331 if (doDevBoundsClip) { | |
332 add_rect_to_clip(pipelineBuilder.clip(), *devBounds, &devBoundsClip); | |
333 } | |
334 const GrClip& clip = doDevBoundsClip ? devBoundsClip : pipelineBuilder.clip( ); | |
335 | |
298 if (clip.isWideOpen(clipSpaceRTIBounds)) { | 336 if (clip.isWideOpen(clipSpaceRTIBounds)) { |
299 this->setPipelineBuilderStencil(pipelineBuilder, ars); | 337 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
300 return true; | 338 return true; |
301 } | 339 } |
302 | 340 |
303 // The clip mask manager always draws with a single IRect so we special case that logic here | 341 // The clip mask manager always draws with a single IRect so we special case that logic here |
304 // Image filters just use a rect, so we also special case that logic | 342 // Image filters just use a rect, so we also special case that logic |
305 switch (clip.clipType()) { | 343 switch (clip.clipType()) { |
306 case GrClip::kWideOpen_ClipType: | 344 case GrClip::kWideOpen_ClipType: |
307 SkFAIL("Should have caught this with clip.isWideOpen()"); | 345 SkFAIL("Should have caught this with clip.isWideOpen()"); |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1106 | 1144 |
1107 //////////////////////////////////////////////////////////////////////////////// | 1145 //////////////////////////////////////////////////////////////////////////////// |
1108 | 1146 |
1109 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc ilAttachment, | 1147 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc ilAttachment, |
1110 GrStencilSettings* settings) { | 1148 GrStencilSettings* settings) { |
1111 if (stencilAttachment) { | 1149 if (stencilAttachment) { |
1112 int stencilBits = stencilAttachment->bits(); | 1150 int stencilBits = stencilAttachment->bits(); |
1113 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1151 this->adjustStencilParams(settings, fClipMode, stencilBits); |
1114 } | 1152 } |
1115 } | 1153 } |
OLD | NEW |