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