chromium/cc/base/index_rect.h

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_BASE_INDEX_RECT_H_
#define CC_BASE_INDEX_RECT_H_

#include <string>

#include "cc/base/base_export.h"

namespace cc {

// This class encapsulates the index boundaries for region on co-ordinate system
// (used for tiling). The delimiting boundaries |left_|, |right_|, |top_| and
// |bottom_| are basically leftmost, rightmost, topmost and bottommost indices
// of the region. These delimiters can span in any quadrants.
//
// If |left_| <= |right_| and |top_| <= |bottom_|, IndexRect is considered to
// hold valid indices and this can be checked using is_valid().
//
// If IndexRect is valid, it has a coverage of all the indices from |left_| to
// |right_| both inclusive and |top_| to |bottom_| both inclusive. So for
// |left_| == |right_|, num_indices_x() is 1, meaning |left_| and |right_| point
// to the same index.
//
// The following diagram shows how indices span in different quadrants and the
// positive quadrant. In the positive quadrant all indices are >= 0. The first
// index in this quadrant is (0, 0). The indices in positive quadrant represent
// the visible region and is_in_positive_quadrant() can be used to check whether
// all indices lie within this quadrant or not.
//
//              │
//              │
//  -ve index_x │  +ve index_x
//  -ve index_y │  -ve index_y
//              │
//  ────────────┼────────────
//              │
//  -ve index_x │  +ve index_x
//  +ve index_y │  +ve index_y
//              │
//              │  (+ve Quadrant)
//
// In the following example, region has |left_| = 0, |right_| = 4, |top_| = 0
// and |bottom_| = 4. Here x indices are 0, 1, 2, 3, 4 and y indices are
// 0, 1, 2, 3, 4.
//
//    x 0   1   2   3   4
//  y ┌───┬───┬───┬───┬───┐
//  0 │   │   │   │   │   │
//    ├───┼───┼───┼───┼───┤
//  1 │   │   │   │   │   │
//    ├───┼───┼───┼───┼───┤
//  2 │   │   │   │   │   │
//    ├───┼───┼───┼───┼───┤
//  3 │   │   │   │   │   │
//    ├───┼───┼───┼───┼───┤
//  4 │   │   │   │   │   │
//    └───┴───┴───┴───┴───┘
class CC_BASE_EXPORT IndexRect {};

inline bool operator==(const IndexRect& lhs, const IndexRect& rhs) {}

inline bool operator!=(const IndexRect& lhs, const IndexRect& rhs) {}

}  // namespace cc

#endif  // CC_BASE_INDEX_RECT_H_