summaryrefslogtreecommitdiff
path: root/libs/hwui/Rect.h
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2010-10-27 18:57:51 -0700
committerRomain Guy <romainguy@google.com>2010-11-02 16:17:23 -0700
commit5b3b35296e8b2c8d3f07d32bb645d5414db41a1d (patch)
treebad2ebdbfeb8a3a0be1591d5a357a8280df7d1d2 /libs/hwui/Rect.h
parent2444ddb3d9b59ec45ba50858fcbff639e59b93b1 (diff)
Optimize FBO drawing with regions.
This optimization is currently disabled until Launcher is modified to take advantage of it. The optimization can be enabled by turning on RENDER_LAYERS_AS_REGIONS in the OpenGLRenderer.h file. Change-Id: I2fdf59d0f4dc690a3d7f712173ab8db3848b27b1
Diffstat (limited to 'libs/hwui/Rect.h')
-rw-r--r--libs/hwui/Rect.h47
1 files changed, 35 insertions, 12 deletions
diff --git a/libs/hwui/Rect.h b/libs/hwui/Rect.h
index 8f3655cbe067..71951b7a3cc8 100644
--- a/libs/hwui/Rect.h
+++ b/libs/hwui/Rect.h
@@ -14,8 +14,10 @@
* limitations under the License.
*/
-#ifndef ANDROID_UI_RECT_H
-#define ANDROID_UI_RECT_H
+#ifndef ANDROID_HWUI_RECT_H
+#define ANDROID_HWUI_RECT_H
+
+#include <cmath>
#include <utils/Log.h>
@@ -32,25 +34,35 @@ struct Rect {
float right;
float bottom;
- Rect():
+ // Used by Region
+ typedef float value_type;
+
+ inline Rect():
left(0),
top(0),
right(0),
bottom(0) {
}
- Rect(float left, float top, float right, float bottom):
+ inline Rect(float left, float top, float right, float bottom):
left(left),
top(top),
right(right),
bottom(bottom) {
}
- Rect(const Rect& r) {
+ inline Rect(float width, float height):
+ left(0.0f),
+ top(0.0f),
+ right(width),
+ bottom(height) {
+ }
+
+ inline Rect(const Rect& r) {
set(r);
}
- Rect(Rect& r) {
+ inline Rect(Rect& r) {
set(r);
}
@@ -72,22 +84,26 @@ struct Rect {
return memcmp(&a, &b, sizeof(a));
}
- bool isEmpty() const {
+ inline void clear() {
+ left = top = right = bottom = 0.0f;
+ }
+
+ inline bool isEmpty() const {
return left >= right || top >= bottom;
}
- void setEmpty() {
- memset(this, 0, sizeof(*this));
+ inline void setEmpty() {
+ left = top = right = bottom = 0.0f;
}
- void set(float left, float top, float right, float bottom) {
+ inline void set(float left, float top, float right, float bottom) {
this->left = left;
this->right = right;
this->top = top;
this->bottom = bottom;
}
- void set(const Rect& r) {
+ inline void set(const Rect& r) {
set(r.left, r.top, r.right, r.bottom);
}
@@ -148,6 +164,13 @@ struct Rect {
return false;
}
+ void translate(float dx, float dy) {
+ left += dx;
+ right += dx;
+ top += dy;
+ bottom += dy;
+ }
+
void snapToPixelBoundaries() {
left = floorf(left + 0.5f);
top = floorf(top + 0.5f);
@@ -164,4 +187,4 @@ struct Rect {
}; // namespace uirenderer
}; // namespace android
-#endif // ANDROID_UI_RECT_H
+#endif // ANDROID_HWUI_RECT_H