OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ | 7 #ifndef CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ |
8 #define CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ | 8 #define CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ |
9 | 9 |
10 #include "core/fxcrt/include/fx_basic.h" | 10 #include "core/fxcrt/include/fx_basic.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 FX_RECT(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {} | 144 FX_RECT(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {} |
145 | 145 |
146 explicit FX_RECT(const FX_SMALL_RECT& other) | 146 explicit FX_RECT(const FX_SMALL_RECT& other) |
147 : FX_RECT(other.left, other.top, other.right, other.bottom) {} | 147 : FX_RECT(other.left, other.top, other.right, other.bottom) {} |
148 | 148 |
149 int Width() const { return right - left; } | 149 int Width() const { return right - left; } |
150 int Height() const { return bottom - top; } | 150 int Height() const { return bottom - top; } |
151 bool IsEmpty() const { return right <= left || bottom <= top; } | 151 bool IsEmpty() const { return right <= left || bottom <= top; } |
152 | 152 |
| 153 bool Valid() const { |
| 154 pdfium::base::CheckedNumeric<int> w = right; |
| 155 pdfium::base::CheckedNumeric<int> h = bottom; |
| 156 w -= left; |
| 157 h -= top; |
| 158 return w.IsValid() && h.IsValid(); |
| 159 } |
| 160 |
153 void Normalize(); | 161 void Normalize(); |
154 | 162 |
155 void Intersect(const FX_RECT& src); | 163 void Intersect(const FX_RECT& src); |
156 void Intersect(int l, int t, int r, int b) { Intersect(FX_RECT(l, t, r, b)); } | 164 void Intersect(int l, int t, int r, int b) { Intersect(FX_RECT(l, t, r, b)); } |
157 | 165 |
158 void Union(const FX_RECT& other_rect); | 166 void Union(const FX_RECT& other_rect); |
159 void Union(int l, int t, int r, int b) { Union(FX_RECT(l, t, r, b)); } | 167 void Union(int l, int t, int r, int b) { Union(FX_RECT(l, t, r, b)); } |
160 | 168 |
161 void Offset(int dx, int dy) { | 169 void Offset(int dx, int dy) { |
162 left += dx; | 170 left += dx; |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 public: | 685 public: |
678 FX_FLOAT a; | 686 FX_FLOAT a; |
679 FX_FLOAT b; | 687 FX_FLOAT b; |
680 FX_FLOAT c; | 688 FX_FLOAT c; |
681 FX_FLOAT d; | 689 FX_FLOAT d; |
682 FX_FLOAT e; | 690 FX_FLOAT e; |
683 FX_FLOAT f; | 691 FX_FLOAT f; |
684 }; | 692 }; |
685 | 693 |
686 #endif // CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ | 694 #endif // CORE_FXCRT_INCLUDE_FX_COORDINATES_H_ |
OLD | NEW |