| 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 "GrFixedClip.h" | 8 #include "GrFixedClip.h" |
| 9 | 9 |
| 10 #include "GrAppliedClip.h" | 10 #include "GrAppliedClip.h" |
| 11 #include "GrDrawContext.h" | 11 #include "GrDrawContext.h" |
| 12 | 12 |
| 13 void GrFixedClip::getConservativeBounds(int width, int height, SkIRect* devResul
t, | 13 bool GrFixedClip::quickContains(const SkRect& rect) const { |
| 14 bool* isIntersectionOfRects) const { | 14 if (!fWindowRectsState.disabled()) { |
| 15 devResult->setXYWH(0, 0, width, height); | 15 return false; |
| 16 } |
| 17 return !fScissorState.enabled() || GrClip::IsInsideClip(fScissorState.rect()
, rect); |
| 18 } |
| 19 |
| 20 void GrFixedClip::getConservativeBounds(int w, int h, SkIRect* devResult, bool*
iior) const { |
| 21 devResult->setXYWH(0, 0, w, h); |
| 16 if (fScissorState.enabled()) { | 22 if (fScissorState.enabled()) { |
| 17 if (!devResult->intersect(fScissorState.rect())) { | 23 if (!devResult->intersect(fScissorState.rect())) { |
| 18 devResult->setEmpty(); | 24 devResult->setEmpty(); |
| 19 } | 25 } |
| 20 } | 26 } |
| 21 if (isIntersectionOfRects) { | 27 if (iior) { |
| 22 *isIntersectionOfRects = true; | 28 *iior = true; |
| 23 } | 29 } |
| 24 } | 30 } |
| 25 | 31 |
| 26 bool GrFixedClip::apply(GrContext*, GrDrawContext* drawContext, bool isHWAntiAli
as, | 32 bool GrFixedClip::isRRect(const SkRect& rtBounds, SkRRect* rr, bool* aa) const { |
| 27 bool hasUserStencilSettings, GrAppliedClip* out) const { | 33 if (!fWindowRectsState.disabled()) { |
| 34 return false; |
| 35 } |
| 28 if (fScissorState.enabled()) { | 36 if (fScissorState.enabled()) { |
| 29 SkIRect tightScissor; | 37 SkRect rect = SkRect::Make(fScissorState.rect()); |
| 30 if (!tightScissor.intersect(fScissorState.rect(), | 38 if (!rect.intersects(rtBounds)) { |
| 31 SkIRect::MakeWH(drawContext->width(), drawCo
ntext->height()))) { | 39 return false; |
| 40 } |
| 41 rr->setRect(rect); |
| 42 *aa = false; |
| 43 return true; |
| 44 } |
| 45 return false; |
| 46 }; |
| 47 |
| 48 bool GrFixedClip::apply(GrContext*, GrDrawContext* dc, bool, bool, GrAppliedClip
* out) const { |
| 49 if (fScissorState.enabled()) { |
| 50 SkIRect tightScissor = SkIRect::MakeWH(dc->width(), dc->height()); |
| 51 if (!tightScissor.intersect(fScissorState.rect())) { |
| 32 return false; | 52 return false; |
| 33 } | 53 } |
| 34 if (IsOutsideClip(tightScissor, out->clippedDrawBounds())) { | 54 if (IsOutsideClip(tightScissor, out->clippedDrawBounds())) { |
| 35 return false; | 55 return false; |
| 36 } | 56 } |
| 37 if (!IsInsideClip(fScissorState.rect(), out->clippedDrawBounds())) { | 57 if (!IsInsideClip(fScissorState.rect(), out->clippedDrawBounds())) { |
| 38 out->addScissor(tightScissor); | 58 out->addScissor(tightScissor); |
| 39 } | 59 } |
| 40 } | 60 } |
| 41 | 61 |
| 62 if (!fWindowRectsState.disabled()) { |
| 63 out->addWindowRectangles(fWindowRectsState); |
| 64 } |
| 65 |
| 42 return true; | 66 return true; |
| 43 } | 67 } |
| 44 | 68 |
| 45 const GrFixedClip& GrFixedClip::Disabled() { | 69 const GrFixedClip& GrFixedClip::Disabled() { |
| 46 static const GrFixedClip disabled = GrFixedClip(); | 70 static const GrFixedClip disabled = GrFixedClip(); |
| 47 return disabled; | 71 return disabled; |
| 48 } | 72 } |
| OLD | NEW |