blob: 60a47738203de7fc8737fc1a8db169473263b565 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2010 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#ifndef GrRect_DEFINED
12#define GrRect_DEFINED
13
14#include "GrPoint.h"
reed@google.com20efde72011-05-09 17:00:02 +000015#include "SkRect.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000016
reed@google.com20efde72011-05-09 17:00:02 +000017typedef SkIRect GrIRect;
18typedef SkRect GrRect;
reed@google.comac10a2d2010-12-22 21:39:39 +000019
20struct GrIRect16 {
21 int16_t fLeft, fTop, fRight, fBottom;
reed@google.com20efde72011-05-09 17:00:02 +000022
reed@google.comac10a2d2010-12-22 21:39:39 +000023 int width() const { return fRight - fLeft; }
24 int height() const { return fBottom - fTop; }
25 int area() const { return this->width() * this->height(); }
26 bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
reed@google.com20efde72011-05-09 17:00:02 +000027
reed@google.comac10a2d2010-12-22 21:39:39 +000028 void set(const GrIRect& r) {
reed@google.com20efde72011-05-09 17:00:02 +000029 fLeft = SkToS16(r.fLeft);
30 fTop = SkToS16(r.fTop);
31 fRight = SkToS16(r.fRight);
32 fBottom = SkToS16(r.fBottom);
bsalomon@google.comd302f142011-03-03 13:54:13 +000033 }
reed@google.comac10a2d2010-12-22 21:39:39 +000034};
35
36#endif
37