GrClipData.h revision 80bacfeb4bda06541e8695bd502229727bccfea
180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2010 Google Inc. 480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * 580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file. 780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef GrClip_DEFINED 1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define GrClip_DEFINED 1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "GrRect.h" 1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkClipStack.h" 1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass GrSurface; 1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/** 2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * GrClipData encapsulates the information required to construct the clip 2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * masks. 'fOrigin' is only non-zero when saveLayer has been called 2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * with an offset bounding box. The clips in 'fClipStack' are in 2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * device coordinates (i.e., they have been translated by -fOrigin w.r.t. 2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * the canvas' device coordinates). 2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass GrClipData : public SkNoncopyable { 2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkClipStack* fClipStack; 2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkIPoint fOrigin; 3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrClipData() 3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru : fClipStack(NULL) { 3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fOrigin.setZero(); 3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool operator==(const GrClipData& other) const { 3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (fOrigin != other.fOrigin) { 3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return false; 3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (NULL != fClipStack && NULL != other.fClipStack) { 4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return *fClipStack == *other.fClipStack; 4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return fClipStack == other.fClipStack; 4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool operator!=(const GrClipData& other) const { 4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return !(*this == other); 5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void getConservativeBounds(const GrSurface* surface, 5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrIRect* devResult, 5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool* isIntersectionOfRects = NULL) const; 5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 59