1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/*
* Copyright 2010 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "GrClip.h"
#include "GrClipMaskManager.h"
#include "GrDrawContext.h"
void GrNoClip::getConservativeBounds(int width, int height, SkIRect* devResult,
bool* isIntersectionOfRects) const {
devResult->setXYWH(0, 0, width, height);
if (isIntersectionOfRects) {
*isIntersectionOfRects = true;
}
}
bool GrFixedClip::quickContains(const SkRect& rect) const {
if (fHasStencilClip) {
return false;
}
if (!fScissorState.enabled()) {
return true;
}
return fScissorState.rect().contains(rect);
}
void GrFixedClip::getConservativeBounds(int width, int height, SkIRect* devResult,
bool* isIntersectionOfRects) const {
devResult->setXYWH(0, 0, width, height);
if (fScissorState.enabled()) {
if (!devResult->intersect(fScissorState.rect())) {
devResult->setEmpty();
}
}
if (isIntersectionOfRects) {
*isIntersectionOfRects = true;
}
}
bool GrFixedClip::apply(GrContext*,
GrDrawContext* drawContext,
const SkRect* devBounds,
bool isHWAntiAlias,
bool hasUserStencilSettings,
GrAppliedClip* out) const {
SkASSERT(!fDeviceBounds.isLargest());
if (fScissorState.enabled()) {
SkIRect tightScissor;
if (!tightScissor.intersect(fScissorState.rect(),
SkIRect::MakeWH(drawContext->width(), drawContext->height()))) {
return false;
}
if (devBounds && !devBounds->intersects(SkRect::Make(tightScissor))) {
return false;
}
if (!devBounds || !CanIgnoreScissor(fScissorState.rect(), *devBounds)) {
if (fHasStencilClip) {
out->makeScissoredStencil(tightScissor, &fDeviceBounds);
} else {
out->makeScissored(tightScissor);
}
return true;
}
}
out->makeStencil(fHasStencilClip, fDeviceBounds);
return true;
}
bool GrClipStackClip::quickContains(const SkRect& rect) const {
if (!fStack) {
return true;
}
return fStack->quickContains(rect.makeOffset(SkIntToScalar(fOrigin.x()),
SkIntToScalar(fOrigin.y())));
}
void GrClipStackClip::getConservativeBounds(int width, int height, SkIRect* devResult,
bool* isIntersectionOfRects) const {
if (!fStack) {
devResult->setXYWH(0, 0, width, height);
if (isIntersectionOfRects) {
*isIntersectionOfRects = true;
}
return;
}
SkRect devBounds;
fStack->getConservativeBounds(-fOrigin.x(), -fOrigin.y(), width, height, &devBounds,
isIntersectionOfRects);
devBounds.roundOut(devResult);
}
bool GrClipStackClip::apply(GrContext* context,
GrDrawContext* drawContext,
const SkRect* devBounds,
bool useHWAA,
bool hasUserStencilSettings,
GrAppliedClip* out) const {
return GrClipMaskManager::SetupClipping(context, drawContext, *this, devBounds,
useHWAA, hasUserStencilSettings, out);
}
|