Add ANativeWindow API for directly drawing to the surface bits.

Also other cleanup and fixes:

- We now properly set the default window format to 565.
- New APIs to set the window format and flags from native code.
- Tweaked glue for simpler handling of the "destroy" message.
- Um, other stuff.

Change-Id: Id7790a21a2fa9a19b91854d225324a7c1e7c6ade
This commit is contained in:
Dianne Hackborn 2010-07-09 11:44:11 -07:00
parent 4865402092
commit 9147d11a5f
2 changed files with 19 additions and 22 deletions

View File

@ -20,31 +20,28 @@
#include <utils/TypeHelpers.h>
#include <ui/Point.h>
#include <android/rect.h>
namespace android {
class Rect
class Rect : public ARect
{
public:
int left;
int top;
int right;
int bottom;
typedef int value_type;
typedef int32_t value_type;
// we don't provide copy-ctor and operator= on purpose
// because we want the compiler generated versions
inline Rect() {
}
inline Rect(int w, int h)
: left(0), top(0), right(w), bottom(h) {
inline Rect(int32_t w, int32_t h) {
left = top = 0; right = w; bottom = h;
}
inline Rect(int l, int t, int r, int b)
: left(l), top(t), right(r), bottom(b) {
inline Rect(int32_t l, int32_t t, int32_t r, int32_t b) {
left = l; top = t; right = r; bottom = b;
}
inline Rect(const Point& lt, const Point& rb)
: left(lt.x), top(lt.y), right(rb.x), bottom(rb.y) {
inline Rect(const Point& lt, const Point& rb) {
left = lt.x; top = lt.y; right = rb.x; bottom = rb.y;
}
void makeInvalid();
@ -68,12 +65,12 @@ public:
}
// rectangle's width
inline int width() const {
inline int32_t width() const {
return right-left;
}
// rectangle's height
inline int height() const {
inline int32_t height() const {
return bottom-top;
}
@ -136,12 +133,12 @@ public:
const Rect operator + (const Point& rhs) const;
const Rect operator - (const Point& rhs) const;
void translate(int dx, int dy) { // legacy, don't use.
void translate(int32_t dx, int32_t dy) { // legacy, don't use.
offsetBy(dx, dy);
}
Rect& offsetTo(int x, int y);
Rect& offsetBy(int x, int y);
Rect& offsetTo(int32_t x, int32_t y);
Rect& offsetBy(int32_t x, int32_t y);
bool intersect(const Rect& with, Rect* result) const;
};

View File

@ -18,11 +18,11 @@
namespace android {
static inline int min(int a, int b) {
static inline int32_t min(int32_t a, int32_t b) {
return (a<b) ? a : b;
}
static inline int max(int a, int b) {
static inline int32_t max(int32_t a, int32_t b) {
return (a>b) ? a : b;
}
@ -53,7 +53,7 @@ bool Rect::operator < (const Rect& rhs) const
return false;
}
Rect& Rect::offsetTo(int x, int y)
Rect& Rect::offsetTo(int32_t x, int32_t y)
{
right -= left - x;
bottom -= top - y;
@ -62,7 +62,7 @@ Rect& Rect::offsetTo(int x, int y)
return *this;
}
Rect& Rect::offsetBy(int x, int y)
Rect& Rect::offsetBy(int32_t x, int32_t y)
{
left += x;
top += y;