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 "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 */ 21 void GrClip::getConservativeBounds(int width, int height, SkIRect* devResult, 22 bool* isIntersectionOfRects) const { 23 switch (fClipType) { 24 case kWideOpen_ClipType: { 25 devResult->setLTRB(0, 0, width, height); 26 if (isIntersectionOfRects) { 27 *isIntersectionOfRects = true; 28 } 29 } break; 30 case kIRect_ClipType: { 31 *devResult = this->irect(); 32 if (isIntersectionOfRects) { 33 *isIntersectionOfRects = true; 34 } 35 } break; 36 case kClipStack_ClipType: { 37 SkRect devBounds; 38 this->clipStack()->getConservativeBounds(-this->origin().fX, 39 -this->origin().fY, 40 width, 41 height, 42 &devBounds, 43 isIntersectionOfRects); 44 devBounds.roundOut(devResult); 45 } break; 46 47 } 48 } 49 50 const GrClip& GrClip::WideOpen() { 51 static const GrClip clip; 52 return clip; 53 } 54