GrFixedClip.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright 2010 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include "src/gpu/GrFixedClip.h"
  8. #include "src/gpu/GrAppliedClip.h"
  9. #include "src/gpu/GrRenderTargetContext.h"
  10. bool GrFixedClip::quickContains(const SkRect& rect) const {
  11. if (fWindowRectsState.enabled()) {
  12. return false;
  13. }
  14. return !fScissorState.enabled() || GrClip::IsInsideClip(fScissorState.rect(), rect);
  15. }
  16. void GrFixedClip::getConservativeBounds(int w, int h, SkIRect* devResult, bool* iior) const {
  17. devResult->setXYWH(0, 0, w, h);
  18. if (fScissorState.enabled()) {
  19. if (!devResult->intersect(fScissorState.rect())) {
  20. devResult->setEmpty();
  21. }
  22. }
  23. if (iior) {
  24. *iior = true;
  25. }
  26. }
  27. bool GrFixedClip::isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA* aa) const {
  28. if (fWindowRectsState.enabled()) {
  29. return false;
  30. }
  31. if (fScissorState.enabled()) {
  32. SkRect rect = SkRect::Make(fScissorState.rect());
  33. if (!rect.intersects(rtBounds)) {
  34. return false;
  35. }
  36. rr->setRect(rect);
  37. *aa = GrAA::kNo;
  38. return true;
  39. }
  40. return false;
  41. };
  42. bool GrFixedClip::apply(int rtWidth, int rtHeight, GrAppliedHardClip* out, SkRect* bounds) const {
  43. if (fScissorState.enabled()) {
  44. SkIRect tightScissor = SkIRect::MakeWH(rtWidth, rtHeight);
  45. if (!tightScissor.intersect(fScissorState.rect())) {
  46. return false;
  47. }
  48. if (IsOutsideClip(tightScissor, *bounds)) {
  49. return false;
  50. }
  51. if (!IsInsideClip(fScissorState.rect(), *bounds)) {
  52. out->addScissor(tightScissor, bounds);
  53. }
  54. }
  55. if (fWindowRectsState.enabled()) {
  56. out->addWindowRectangles(fWindowRectsState);
  57. }
  58. return true;
  59. }
  60. const GrFixedClip& GrFixedClip::Disabled() {
  61. static const GrFixedClip disabled = GrFixedClip();
  62. return disabled;
  63. }