diff options
author | Romain Guy <romainguy@android.com> | 2010-07-16 14:12:24 -0700 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2010-07-16 14:12:24 -0700 |
commit | 079ba2c85b15e882629b8d188f5fbdb42f7f8eea (patch) | |
tree | dcdad4233c75952bea11e4d5b945996a0f930a9a /core | |
parent | ebd6f94dbdafdb14d620d2bd8e08535a309f266a (diff) | |
download | frameworks_base-079ba2c85b15e882629b8d188f5fbdb42f7f8eea.zip frameworks_base-079ba2c85b15e882629b8d188f5fbdb42f7f8eea.tar.gz frameworks_base-079ba2c85b15e882629b8d188f5fbdb42f7f8eea.tar.bz2 |
Improve clip support (add intersect, union and replace.)
This change also modifies the way the clip is stored. The clip is now
always stored in screen-space coordinates.
Change-Id: I96375784d82dfe975bc6477a159e6866e7052487
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/view/GLES20Canvas.java | 24 | ||||
-rw-r--r-- | core/jni/android_view_GLES20Canvas.cpp | 15 |
2 files changed, 21 insertions, 18 deletions
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java index a2ab8bd..676aae3 100644 --- a/core/java/android/view/GLES20Canvas.java +++ b/core/java/android/view/GLES20Canvas.java @@ -149,43 +149,44 @@ class GLES20Canvas extends Canvas { @Override public boolean clipRect(float left, float top, float right, float bottom) { - return nClipRect(mRenderer, left, top, right, bottom); + return nClipRect(mRenderer, left, top, right, bottom, Region.Op.INTERSECT.nativeInt); } - private native boolean nClipRect(int renderer, float left, float top, float right, float bottom); + private native boolean nClipRect(int renderer, float left, float top, + float right, float bottom, int op); @Override public boolean clipRect(float left, float top, float right, float bottom, Region.Op op) { - throw new UnsupportedOperationException(); + return nClipRect(mRenderer, left, top, right, bottom, op.nativeInt); } @Override public boolean clipRect(int left, int top, int right, int bottom) { - return nClipRect(mRenderer, left, top, right, bottom); + return nClipRect(mRenderer, left, top, right, bottom, Region.Op.INTERSECT.nativeInt); } - private native boolean nClipRect(int renderer, int left, int top, int right, int bottom); + private native boolean nClipRect(int renderer, int left, int top, int right, int bottom, int op); @Override public boolean clipRect(Rect rect) { - return clipRect(rect.left, rect.top, rect.right, rect.bottom); + return nClipRect(mRenderer, rect.left, rect.top, rect.right, rect.bottom, + Region.Op.INTERSECT.nativeInt); } @Override public boolean clipRect(Rect rect, Region.Op op) { - // TODO: Implement - throw new UnsupportedOperationException(); + return nClipRect(mRenderer, rect.left, rect.top, rect.right, rect.bottom, op.nativeInt); } @Override public boolean clipRect(RectF rect) { - return clipRect(rect.left, rect.top, rect.right, rect.bottom); + return nClipRect(mRenderer, rect.left, rect.top, rect.right, rect.bottom, + Region.Op.INTERSECT.nativeInt); } @Override public boolean clipRect(RectF rect, Region.Op op) { - // TODO: Implement - throw new UnsupportedOperationException(); + return nClipRect(mRenderer, rect.left, rect.top, rect.right, rect.bottom, op.nativeInt); } @Override @@ -347,7 +348,6 @@ class GLES20Canvas extends Canvas { @Override public void setDrawFilter(DrawFilter filter) { - // Don't crash, but ignore the draw filter // TODO: Implement PaintDrawFilter mFilter = filter; } diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp index dbf482e..e5aa5dd 100644 --- a/core/jni/android_view_GLES20Canvas.cpp +++ b/core/jni/android_view_GLES20Canvas.cpp @@ -23,6 +23,7 @@ #include <SkCanvas.h> #include <SkMatrix.h> #include <SkPaint.h> +#include <SkRegion.h> #include <SkXfermode.h> #include <OpenGLRenderer.h> @@ -120,13 +121,15 @@ static bool android_view_GLES20Canvas_quickReject(JNIEnv* env, jobject canvas, } static bool android_view_GLES20Canvas_clipRectF(JNIEnv* env, jobject canvas, - OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom) { - return renderer->clipRect(left, top, right, bottom); + OpenGLRenderer* renderer, jfloat left, jfloat top, jfloat right, jfloat bottom, + SkRegion::Op op) { + return renderer->clipRect(left, top, right, bottom, op); } static bool android_view_GLES20Canvas_clipRect(JNIEnv* env, jobject canvas, - OpenGLRenderer* renderer, jint left, jint top, jint right, jint bottom) { - return renderer->clipRect(float(left), float(top), float(right), float(bottom)); + OpenGLRenderer* renderer, jint left, jint top, jint right, jint bottom, + SkRegion::Op op) { + return renderer->clipRect(float(left), float(top), float(right), float(bottom), op); } static bool android_view_GLES20Canvas_getClipBounds(JNIEnv* env, jobject canvas, @@ -257,8 +260,8 @@ static JNINativeMethod gMethods[] = { { "nSaveLayerAlpha", "(IFFFFII)I", (void*) android_view_GLES20Canvas_saveLayerAlpha }, { "nQuickReject", "(IFFFFI)Z", (void*) android_view_GLES20Canvas_quickReject }, - { "nClipRect", "(IFFFF)Z", (void*) android_view_GLES20Canvas_clipRectF }, - { "nClipRect", "(IIIII)Z", (void*) android_view_GLES20Canvas_clipRect }, + { "nClipRect", "(IFFFFI)Z", (void*) android_view_GLES20Canvas_clipRectF }, + { "nClipRect", "(IIIIII)Z", (void*) android_view_GLES20Canvas_clipRect }, { "nTranslate", "(IFF)V", (void*) android_view_GLES20Canvas_translate }, { "nRotate", "(IF)V", (void*) android_view_GLES20Canvas_rotate }, |