blob: 0f8aac874953237dfd03323c516d2879b2edfc38 [file] [log] [blame]
joshualitt44701df2015-02-23 14:44:57 -08001/*
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 "GrClip.h"
9
10#include "GrSurface.h"
11#include "SkRect.h"
12
13///////////////////////////////////////////////////////////////////////////////
14
15/**
16 * getConservativeBounds returns the conservative bounding box of the clip
17 * in device (as opposed to canvas) coordinates. If the bounding box is
18 * the result of purely intersections of rects (with an initial replace)
19 * isIntersectionOfRects will be set to true.
20 */
21void GrClip::getConservativeBounds(int width, int height, SkIRect* devResult,
22 bool* isIntersectionOfRects) const {
23 switch (fClipType) {
24 default:
25 SkFAIL("incomplete switch\n");
26 case kWideOpen_ClipType: {
27 devResult->setLTRB(0, 0, width, height);
28 if (isIntersectionOfRects) {
29 *isIntersectionOfRects = true;
30 }
31 } break;
32 case kIRect_ClipType: {
33 *devResult = this->irect();
34 if (isIntersectionOfRects) {
35 *isIntersectionOfRects = true;
36 }
37 } break;
38 case kClipStack_ClipType: {
39 SkRect devBounds;
40 this->clipStack()->getConservativeBounds(-this->origin().fX,
41 -this->origin().fY,
42 width,
43 height,
44 &devBounds,
45 isIntersectionOfRects);
46 devBounds.roundOut(devResult);
47 } break;
48
49 }
50}