144701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt/* 244701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt * Copyright 2010 Google Inc. 344701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt * 444701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt * Use of this source code is governed by a BSD-style license that can be 544701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt * found in the LICENSE file. 644701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt */ 744701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt 844701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt#include "GrClip.h" 944701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt 1044701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt#include "GrSurface.h" 1144701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt#include "SkRect.h" 1244701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt 1344701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt/////////////////////////////////////////////////////////////////////////////// 1444701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt 1544701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt/** 1644701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt * getConservativeBounds returns the conservative bounding box of the clip 1744701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt * in device (as opposed to canvas) coordinates. If the bounding box is 1844701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt * the result of purely intersections of rects (with an initial replace) 1944701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt * isIntersectionOfRects will be set to true. 2044701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt */ 2144701df5ce572ac3cccec785cf52103d3d5d14a5joshualittvoid GrClip::getConservativeBounds(int width, int height, SkIRect* devResult, 2244701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt bool* isIntersectionOfRects) const { 2344701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt switch (fClipType) { 2444701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt case kWideOpen_ClipType: { 2544701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt devResult->setLTRB(0, 0, width, height); 2644701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt if (isIntersectionOfRects) { 2744701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt *isIntersectionOfRects = true; 2844701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt } 2944701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt } break; 3044701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt case kIRect_ClipType: { 3144701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt *devResult = this->irect(); 3244701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt if (isIntersectionOfRects) { 3344701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt *isIntersectionOfRects = true; 3444701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt } 3544701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt } break; 3644701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt case kClipStack_ClipType: { 3744701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt SkRect devBounds; 3844701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt this->clipStack()->getConservativeBounds(-this->origin().fX, 3944701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt -this->origin().fY, 4044701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt width, 4144701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt height, 4244701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt &devBounds, 4344701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt isIntersectionOfRects); 4444701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt devBounds.roundOut(devResult); 4544701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt } break; 4644701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt 4744701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt } 4844701df5ce572ac3cccec785cf52103d3d5d14a5joshualitt} 499ece6a95481c3226b4519c8e9f685eb3fc1873b3joshualitt 509ece6a95481c3226b4519c8e9f685eb3fc1873b3joshualittconst GrClip& GrClip::WideOpen() { 51ab2f44cbfab6d2e0e09c93c41932f464a061742djoshualitt static const GrClip clip; 529ece6a95481c3226b4519c8e9f685eb3fc1873b3joshualitt return clip; 539ece6a95481c3226b4519c8e9f685eb3fc1873b3joshualitt} 54