| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 "GrClip.h" | 8 #include "GrClip.h" |
| 9 | 9 |
| 10 #include "GrClipMaskManager.h" | 10 #include "GrClipMaskManager.h" |
| 11 #include "GrDrawContext.h" |
| 11 | 12 |
| 12 void GrNoClip::getConservativeBounds(int width, int height, SkIRect* devResult, | 13 void GrNoClip::getConservativeBounds(int width, int height, SkIRect* devResult, |
| 13 bool* isIntersectionOfRects) const { | 14 bool* isIntersectionOfRects) const { |
| 14 devResult->setXYWH(0, 0, width, height); | 15 devResult->setXYWH(0, 0, width, height); |
| 15 if (isIntersectionOfRects) { | 16 if (isIntersectionOfRects) { |
| 16 *isIntersectionOfRects = true; | 17 *isIntersectionOfRects = true; |
| 17 } | 18 } |
| 18 } | 19 } |
| 19 | 20 |
| 20 bool GrFixedClip::quickContains(const SkRect& rect) const { | 21 bool GrFixedClip::quickContains(const SkRect& rect) const { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 33 if (fScissorState.enabled()) { | 34 if (fScissorState.enabled()) { |
| 34 if (!devResult->intersect(fScissorState.rect())) { | 35 if (!devResult->intersect(fScissorState.rect())) { |
| 35 devResult->setEmpty(); | 36 devResult->setEmpty(); |
| 36 } | 37 } |
| 37 } | 38 } |
| 38 if (isIntersectionOfRects) { | 39 if (isIntersectionOfRects) { |
| 39 *isIntersectionOfRects = true; | 40 *isIntersectionOfRects = true; |
| 40 } | 41 } |
| 41 } | 42 } |
| 42 | 43 |
| 43 bool GrFixedClip::apply(GrClipMaskManager*, const GrPipelineBuilder& pipelineBui
lder, | 44 bool GrFixedClip::apply(GrContext*, const GrPipelineBuilder& pipelineBuilder, |
| 45 GrDrawContext* drawContext, |
| 44 const SkRect* devBounds, GrAppliedClip* out) const { | 46 const SkRect* devBounds, GrAppliedClip* out) const { |
| 45 if (fScissorState.enabled()) { | 47 if (fScissorState.enabled()) { |
| 46 const GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | |
| 47 SkIRect tightScissor; | 48 SkIRect tightScissor; |
| 48 if (!tightScissor.intersect(fScissorState.rect(), | 49 if (!tightScissor.intersect(fScissorState.rect(), |
| 49 SkIRect::MakeWH(rt->width(), rt->height())))
{ | 50 SkIRect::MakeWH(drawContext->width(), drawCo
ntext->height()))) { |
| 50 return false; | 51 return false; |
| 51 } | 52 } |
| 52 if (devBounds && !devBounds->intersects(SkRect::Make(tightScissor))) { | 53 if (devBounds && !devBounds->intersects(SkRect::Make(tightScissor))) { |
| 53 return false; | 54 return false; |
| 54 } | 55 } |
| 55 out->makeScissoredStencil(fHasStencilClip, tightScissor); | 56 out->makeScissoredStencil(fHasStencilClip, tightScissor); |
| 56 return true; | 57 return true; |
| 57 } | 58 } |
| 58 | 59 |
| 59 out->makeStencil(fHasStencilClip); | 60 out->makeStencil(fHasStencilClip); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 76 *isIntersectionOfRects = true; | 77 *isIntersectionOfRects = true; |
| 77 } | 78 } |
| 78 return; | 79 return; |
| 79 } | 80 } |
| 80 SkRect devBounds; | 81 SkRect devBounds; |
| 81 fStack->getConservativeBounds(-fOrigin.x(), -fOrigin.y(), width, height, &de
vBounds, | 82 fStack->getConservativeBounds(-fOrigin.x(), -fOrigin.y(), width, height, &de
vBounds, |
| 82 isIntersectionOfRects); | 83 isIntersectionOfRects); |
| 83 devBounds.roundOut(devResult); | 84 devBounds.roundOut(devResult); |
| 84 } | 85 } |
| 85 | 86 |
| 86 bool GrClipStackClip::apply(GrClipMaskManager* clipMaskManager, | 87 bool GrClipStackClip::apply(GrContext* context, |
| 87 const GrPipelineBuilder& pipelineBuilder, const SkRe
ct* devBounds, | 88 const GrPipelineBuilder& pipelineBuilder, GrDrawCont
ext* drawContext, |
| 88 GrAppliedClip* out) const { | 89 const SkRect* devBounds, GrAppliedClip* out) const { |
| 89 // TODO: Collapse ClipMaskManager into this class.(?) | 90 return GrClipMaskManager::SetupClipping(context, pipelineBuilder, drawContex
t, |
| 90 return clipMaskManager->setupClipping(pipelineBuilder, *this, devBounds, out
); | 91 *this, devBounds, out); |
| 91 } | 92 } |
| OLD | NEW |