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; |
| 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 } |
| 307 |
275 //////////////////////////////////////////////////////////////////////////////// | 308 //////////////////////////////////////////////////////////////////////////////// |
276 // sort out what kind of clip mask needs to be created: alpha, stencil, | 309 // sort out what kind of clip mask needs to be created: alpha, stencil, |
277 // scissor, or entirely software | 310 // scissor, or entirely software |
278 bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder, | 311 bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder, |
279 GrPipelineBuilder::AutoRestoreStencil* ars
, | 312 GrPipelineBuilder::AutoRestoreStencil* ars
, |
280 const SkRect* devBounds, | 313 const SkRect* devBounds, |
281 GrAppliedClip* out) { | 314 GrAppliedClip* out) { |
282 if (kRespectClip_StencilClipMode == fClipMode) { | 315 if (kRespectClip_StencilClipMode == fClipMode) { |
283 fClipMode = kIgnoreClip_StencilClipMode; | 316 fClipMode = kIgnoreClip_StencilClipMode; |
284 } | 317 } |
285 | 318 |
286 GrReducedClip::ElementList elements; | 319 GrReducedClip::ElementList elements; |
287 int32_t genID = 0; | 320 int32_t genID = 0; |
288 GrReducedClip::InitialState initialState = GrReducedClip::kAllIn_InitialStat
e; | 321 GrReducedClip::InitialState initialState = GrReducedClip::kAllIn_InitialStat
e; |
289 SkIRect clipSpaceIBounds; | 322 SkIRect clipSpaceIBounds; |
290 bool requiresAA = false; | 323 bool requiresAA = false; |
291 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 324 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
292 | 325 |
293 // GrDrawTarget should have filtered this for us | 326 // GrDrawTarget should have filtered this for us |
294 SkASSERT(rt); | 327 SkASSERT(rt); |
295 | 328 |
296 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); | 329 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); |
297 const GrClip& clip = pipelineBuilder.clip(); | 330 GrClip devBoundsClip; |
| 331 bool doDevBoundsClip = fDebugClipBatchToBounds && devBounds; |
| 332 if (doDevBoundsClip) { |
| 333 add_rect_to_clip(pipelineBuilder.clip(), *devBounds, &devBoundsClip); |
| 334 } |
| 335 const GrClip& clip = doDevBoundsClip ? devBoundsClip : pipelineBuilder.clip(
); |
| 336 |
298 if (clip.isWideOpen(clipSpaceRTIBounds)) { | 337 if (clip.isWideOpen(clipSpaceRTIBounds)) { |
299 this->setPipelineBuilderStencil(pipelineBuilder, ars); | 338 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
300 return true; | 339 return true; |
301 } | 340 } |
302 | 341 |
303 // The clip mask manager always draws with a single IRect so we special case
that logic here | 342 // 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 | 343 // Image filters just use a rect, so we also special case that logic |
305 switch (clip.clipType()) { | 344 switch (clip.clipType()) { |
306 case GrClip::kWideOpen_ClipType: | 345 case GrClip::kWideOpen_ClipType: |
307 SkFAIL("Should have caught this with clip.isWideOpen()"); | 346 SkFAIL("Should have caught this with clip.isWideOpen()"); |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 | 1145 |
1107 //////////////////////////////////////////////////////////////////////////////// | 1146 //////////////////////////////////////////////////////////////////////////////// |
1108 | 1147 |
1109 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, | 1148 void GrClipMaskManager::adjustPathStencilParams(const GrStencilAttachment* stenc
ilAttachment, |
1110 GrStencilSettings* settings) { | 1149 GrStencilSettings* settings) { |
1111 if (stencilAttachment) { | 1150 if (stencilAttachment) { |
1112 int stencilBits = stencilAttachment->bits(); | 1151 int stencilBits = stencilAttachment->bits(); |
1113 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1152 this->adjustStencilParams(settings, fClipMode, stencilBits); |
1114 } | 1153 } |
1115 } | 1154 } |
OLD | NEW |