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