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 #ifndef GrRect_DEFINED 9 #define GrRect_DEFINED 10 11 #include "SkTypes.h" 12 #include "SkRect.h" 13 14 struct GrIRect16 { 15 int16_t fLeft, fTop, fRight, fBottom; 16 MakeEmptyGrIRect1617 static GrIRect16 SK_WARN_UNUSED_RESULT MakeEmpty() { 18 GrIRect16 r; 19 r.setEmpty(); 20 return r; 21 } 22 widthGrIRect1623 int width() const { return fRight - fLeft; } heightGrIRect1624 int height() const { return fBottom - fTop; } areaGrIRect1625 int area() const { return this->width() * this->height(); } isEmptyGrIRect1626 bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; } 27 setEmptyGrIRect1628 void setEmpty() { memset(this, 0, sizeof(*this)); } 29 setGrIRect1630 void set(const SkIRect& r) { 31 fLeft = SkToS16(r.fLeft); 32 fTop = SkToS16(r.fTop); 33 fRight = SkToS16(r.fRight); 34 fBottom = SkToS16(r.fBottom); 35 } 36 }; 37 38 #endif 39