diff options
author | Mathias Agopian <mathias@google.com> | 2013-02-15 22:08:31 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-02-15 22:08:40 +0000 |
commit | ceec31b7dab6a23e443d5dcbcfac4a23b720cfde (patch) | |
tree | fca56e7e18211765df70337c1428462c8106372b /core/jni | |
parent | aa8307b991b9fca5403b5d7f43659b92527af4fd (diff) | |
parent | 52800617946c456e78ed010c82d0ec4358368164 (diff) | |
download | frameworks_base-ceec31b7dab6a23e443d5dcbcfac4a23b720cfde.zip frameworks_base-ceec31b7dab6a23e443d5dcbcfac4a23b720cfde.tar.gz frameworks_base-ceec31b7dab6a23e443d5dcbcfac4a23b720cfde.tar.bz2 |
Merge changes I5a218ca1,I853a76d9
* changes:
Refactoring: Rename SurfaceTextureClient to Surface
clean-up following Surface split
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/android/graphics/SurfaceTexture.cpp | 6 | ||||
-rw-r--r-- | core/jni/android_media_RemoteDisplay.cpp | 2 | ||||
-rw-r--r-- | core/jni/android_opengl_EGL14.cpp | 4 | ||||
-rw-r--r-- | core/jni/android_view_Surface.cpp | 65 | ||||
-rw-r--r-- | core/jni/android_view_SurfaceControl.cpp | 32 | ||||
-rw-r--r-- | core/jni/android_view_TextureView.cpp | 4 | ||||
-rw-r--r-- | core/jni/com_google_android_gles_jni_EGLImpl.cpp | 4 |
7 files changed, 63 insertions, 54 deletions
diff --git a/core/jni/android/graphics/SurfaceTexture.cpp b/core/jni/android/graphics/SurfaceTexture.cpp index f8715fe..296d9b2 100644 --- a/core/jni/android/graphics/SurfaceTexture.cpp +++ b/core/jni/android/graphics/SurfaceTexture.cpp @@ -19,7 +19,7 @@ #include <stdio.h> #include <gui/GLConsumer.h> -#include <gui/SurfaceTextureClient.h> +#include <gui/Surface.h> #include <android_runtime/AndroidRuntime.h> @@ -86,8 +86,8 @@ sp<ANativeWindow> android_SurfaceTexture_getNativeWindow( JNIEnv* env, jobject thiz) { sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz)); - sp<SurfaceTextureClient> surfaceTextureClient(surfaceTexture != NULL ? - new SurfaceTextureClient(surfaceTexture->getBufferQueue()) : NULL); + sp<Surface> surfaceTextureClient(surfaceTexture != NULL ? + new Surface(surfaceTexture->getBufferQueue()) : NULL); return surfaceTextureClient; } diff --git a/core/jni/android_media_RemoteDisplay.cpp b/core/jni/android_media_RemoteDisplay.cpp index a340fa1..80d13be 100644 --- a/core/jni/android_media_RemoteDisplay.cpp +++ b/core/jni/android_media_RemoteDisplay.cpp @@ -64,7 +64,7 @@ public: uint32_t width, uint32_t height, uint32_t flags) { JNIEnv* env = AndroidRuntime::getJNIEnv(); - jobject surfaceObj = android_view_Surface_createFromISurfaceTexture(env, bufferProducer); + jobject surfaceObj = android_view_Surface_createFromIGraphicBufferProducer(env, bufferProducer); if (surfaceObj == NULL) { ALOGE("Could not create Surface from surface texture %p provided by media server.", bufferProducer.get()); diff --git a/core/jni/android_opengl_EGL14.cpp b/core/jni/android_opengl_EGL14.cpp index 9c7124a..26fc261 100644 --- a/core/jni/android_opengl_EGL14.cpp +++ b/core/jni/android_opengl_EGL14.cpp @@ -29,7 +29,7 @@ #include <gui/Surface.h> #include <gui/GLConsumer.h> -#include <gui/SurfaceTextureClient.h> +#include <gui/Surface.h> #include <ui/ANativeObjectBase.h> @@ -631,7 +631,7 @@ not_valid_surface: if (surfaceTexture == NULL) goto not_valid_surface; - window = new android::SurfaceTextureClient(surfaceTexture->getBufferQueue()); + window = new android::Surface(surfaceTexture->getBufferQueue()); if (window == NULL) goto not_valid_surface; diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp index 6f71868..e5a31e5 100644 --- a/core/jni/android_view_Surface.cpp +++ b/core/jni/android_view_Surface.cpp @@ -28,6 +28,7 @@ #include <android_runtime/android_graphics_SurfaceTexture.h> #include <gui/Surface.h> +#include <gui/SurfaceControl.h> #include <gui/GLConsumer.h> #include <ui/Rect.h> @@ -85,7 +86,7 @@ sp<Surface> android_view_Surface_getSurface(JNIEnv* env, jobject surfaceObj) { env->GetIntField(surfaceObj, gSurfaceClassInfo.mNativeObject)); } -jobject android_view_Surface_createFromISurfaceTexture(JNIEnv* env, +jobject android_view_Surface_createFromIGraphicBufferProducer(JNIEnv* env, const sp<IGraphicBufferProducer>& bufferProducer) { if (bufferProducer == NULL) { return NULL; @@ -111,7 +112,13 @@ jobject android_view_Surface_createFromISurfaceTexture(JNIEnv* env, // ---------------------------------------------------------------------------- -static jint nativeCreateFromSurfaceTexture(JNIEnv* env, jobject surfaceObj, +static bool isSurfaceValid(const sp<Surface>& sur) { + return sur != 0 && sur->getISurfaceTexture() != 0; +} + +// ---------------------------------------------------------------------------- + +static jint nativeCreateFromSurfaceTexture(JNIEnv* env, jclass clazz, jobject surfaceTextureObj) { sp<GLConsumer> st(SurfaceTexture_getSurfaceTexture(env, surfaceTextureObj)); if (st == NULL) { @@ -127,28 +134,28 @@ static jint nativeCreateFromSurfaceTexture(JNIEnv* env, jobject surfaceObj, return 0; } - surface->incStrong(surfaceObj); + surface->incStrong(clazz); return int(surface.get()); } -static void nativeRelease(JNIEnv* env, jobject surfaceObj, jint nativeObject) { +static void nativeRelease(JNIEnv* env, jclass clazz, jint nativeObject) { sp<Surface> sur(reinterpret_cast<Surface *>(nativeObject)); - sur->decStrong(surfaceObj); + sur->decStrong(clazz); } -static void nativeDestroy(JNIEnv* env, jobject surfaceObj, jint nativeObject) { +static void nativeDestroy(JNIEnv* env, jclass clazz, jint nativeObject) { sp<Surface> sur(reinterpret_cast<Surface *>(nativeObject)); - sur->decStrong(surfaceObj); + sur->decStrong(clazz); } -static jboolean nativeIsValid(JNIEnv* env, jobject surfaceObj, jint nativeObject) { +static jboolean nativeIsValid(JNIEnv* env, jclass clazz, jint nativeObject) { sp<Surface> sur(reinterpret_cast<Surface *>(nativeObject)); - return Surface::isValid(sur) ? JNI_TRUE : JNI_FALSE; + return isSurfaceValid(sur) ? JNI_TRUE : JNI_FALSE; } -static jboolean nativeIsConsumerRunningBehind(JNIEnv* env, jobject surfaceObj, jint nativeObject) { +static jboolean nativeIsConsumerRunningBehind(JNIEnv* env, jclass clazz, jint nativeObject) { sp<Surface> sur(reinterpret_cast<Surface *>(nativeObject)); - if (!Surface::isValid(sur)) { + if (!isSurfaceValid(sur)) { doThrowIAE(env); return JNI_FALSE; } @@ -176,7 +183,7 @@ static inline SkBitmap::Config convertPixelFormat(PixelFormat format) { static jobject nativeLockCanvas(JNIEnv* env, jobject surfaceObj, jint nativeObject, jobject dirtyRectObj) { sp<Surface> surface(reinterpret_cast<Surface *>(nativeObject)); - if (!Surface::isValid(surface)) { + if (!isSurfaceValid(surface)) { doThrowIAE(env); return NULL; } @@ -196,9 +203,11 @@ static jobject nativeLockCanvas(JNIEnv* env, jobject surfaceObj, jint nativeObje dirtyRegion.set(Rect(0x3FFF, 0x3FFF)); } - Surface::SurfaceInfo info; - status_t err = surface->lock(&info, &dirtyRegion); + ANativeWindow_Buffer outBuffer; + Rect dirtyBounds(dirtyRegion.getBounds()); + status_t err = surface->lock(&outBuffer, &dirtyBounds); if (err < 0) { + dirtyRegion.set(dirtyBounds); const char* const exception = (err == NO_MEMORY) ? OutOfResourcesException : "java/lang/IllegalArgumentException"; @@ -208,18 +217,18 @@ static jobject nativeLockCanvas(JNIEnv* env, jobject surfaceObj, jint nativeObje // Associate a SkCanvas object to this surface jobject canvasObj = env->GetObjectField(surfaceObj, gSurfaceClassInfo.mCanvas); - env->SetIntField(canvasObj, gCanvasClassInfo.mSurfaceFormat, info.format); + env->SetIntField(canvasObj, gCanvasClassInfo.mSurfaceFormat, outBuffer.format); SkCanvas* nativeCanvas = reinterpret_cast<SkCanvas*>( env->GetIntField(canvasObj, gCanvasClassInfo.mNativeCanvas)); SkBitmap bitmap; - ssize_t bpr = info.s * bytesPerPixel(info.format); - bitmap.setConfig(convertPixelFormat(info.format), info.w, info.h, bpr); - if (info.format == PIXEL_FORMAT_RGBX_8888) { + ssize_t bpr = outBuffer.stride * bytesPerPixel(outBuffer.format); + bitmap.setConfig(convertPixelFormat(outBuffer.format), outBuffer.width, outBuffer.height, bpr); + if (outBuffer.format == PIXEL_FORMAT_RGBX_8888) { bitmap.setIsOpaque(true); } - if (info.w > 0 && info.h > 0) { - bitmap.setPixels(info.bits); + if (outBuffer.width > 0 && outBuffer.height > 0) { + bitmap.setPixels(outBuffer.bits); } else { // be safe with an empty bitmap. bitmap.setPixels(NULL); @@ -263,7 +272,7 @@ static void nativeUnlockCanvasAndPost(JNIEnv* env, jobject surfaceObj, jint nati } sp<Surface> surface(reinterpret_cast<Surface *>(nativeObject)); - if (!Surface::isValid(surface)) { + if (!isSurfaceValid(surface)) { return; } @@ -284,7 +293,7 @@ static void nativeUnlockCanvasAndPost(JNIEnv* env, jobject surfaceObj, jint nati // ---------------------------------------------------------------------------- -static jint nativeCopyFrom(JNIEnv* env, jobject surfaceObj, +static jint nativeCopyFrom(JNIEnv* env, jclass clazz, jint nativeObject, jint surfaceControlNativeObj) { /* * This is used by the WindowManagerService just after constructing @@ -295,18 +304,18 @@ static jint nativeCopyFrom(JNIEnv* env, jobject surfaceObj, sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(surfaceControlNativeObj)); sp<Surface> other(ctrl->getSurface()); if (other != NULL) { - other->incStrong(surfaceObj); + other->incStrong(clazz); } sp<Surface> sur(reinterpret_cast<Surface *>(nativeObject)); if (sur != NULL) { - sur->decStrong(surfaceObj); + sur->decStrong(clazz); } return int(other.get()); } -static jint nativeReadFromParcel(JNIEnv* env, jobject surfaceObj, +static jint nativeReadFromParcel(JNIEnv* env, jclass clazz, jint nativeObject, jobject parcelObj) { Parcel* parcel = parcelForJavaObject(env, parcelObj); if (parcel == NULL) { @@ -315,16 +324,16 @@ static jint nativeReadFromParcel(JNIEnv* env, jobject surfaceObj, } sp<Surface> self(reinterpret_cast<Surface *>(nativeObject)); if (self != NULL) { - self->decStrong(surfaceObj); + self->decStrong(clazz); } sp<Surface> sur(Surface::readFromParcel(*parcel)); if (sur != NULL) { - sur->incStrong(surfaceObj); + sur->incStrong(clazz); } return int(sur.get()); } -static void nativeWriteToParcel(JNIEnv* env, jobject surfaceObj, +static void nativeWriteToParcel(JNIEnv* env, jclass clazz, jint nativeObject, jobject parcelObj) { Parcel* parcel = parcelForJavaObject(env, parcelObj); if (parcel == NULL) { diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index 7398895..e477e54 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -120,7 +120,7 @@ private: // ---------------------------------------------------------------------------- -static jint nativeCreate(JNIEnv* env, jobject surfaceObj, jobject sessionObj, +static jint nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj, jstring nameStr, jint w, jint h, jint format, jint flags) { ScopedUtfChars name(env, nameStr); sp<SurfaceComposerClient> client(android_view_SurfaceSession_getClient(env, sessionObj)); @@ -130,19 +130,19 @@ static jint nativeCreate(JNIEnv* env, jobject surfaceObj, jobject sessionObj, jniThrowException(env, OutOfResourcesException, NULL); return 0; } - surface->incStrong(surfaceObj); + surface->incStrong(clazz); return int(surface.get()); } -static void nativeRelease(JNIEnv* env, jobject surfaceObj, jint nativeObject) { +static void nativeRelease(JNIEnv* env, jclass clazz, jint nativeObject) { sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject)); - ctrl->decStrong(surfaceObj); + ctrl->decStrong(clazz); } -static void nativeDestroy(JNIEnv* env, jobject surfaceObj, jint nativeObject) { +static void nativeDestroy(JNIEnv* env, jclass clazz, jint nativeObject) { sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject)); ctrl->clear(); - ctrl->decStrong(surfaceObj); + ctrl->decStrong(clazz); } static inline SkBitmap::Config convertPixelFormat(PixelFormat format) { @@ -210,7 +210,7 @@ static void nativeSetAnimationTransaction(JNIEnv* env, jclass clazz) { SurfaceComposerClient::setAnimationTransaction(); } -static void nativeSetLayer(JNIEnv* env, jobject surfaceObj, jint nativeObject, jint zorder) { +static void nativeSetLayer(JNIEnv* env, jclass clazz, jint nativeObject, jint zorder) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setLayer(zorder); if (err < 0 && err != NO_INIT) { @@ -218,7 +218,7 @@ static void nativeSetLayer(JNIEnv* env, jobject surfaceObj, jint nativeObject, j } } -static void nativeSetPosition(JNIEnv* env, jobject surfaceObj, jint nativeObject, jfloat x, jfloat y) { +static void nativeSetPosition(JNIEnv* env, jclass clazz, jint nativeObject, jfloat x, jfloat y) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setPosition(x, y); if (err < 0 && err != NO_INIT) { @@ -226,7 +226,7 @@ static void nativeSetPosition(JNIEnv* env, jobject surfaceObj, jint nativeObject } } -static void nativeSetSize(JNIEnv* env, jobject surfaceObj, jint nativeObject, jint w, jint h) { +static void nativeSetSize(JNIEnv* env, jclass clazz, jint nativeObject, jint w, jint h) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setSize(w, h); if (err < 0 && err != NO_INIT) { @@ -234,7 +234,7 @@ static void nativeSetSize(JNIEnv* env, jobject surfaceObj, jint nativeObject, ji } } -static void nativeSetFlags(JNIEnv* env, jobject surfaceObj, jint nativeObject, jint flags, jint mask) { +static void nativeSetFlags(JNIEnv* env, jclass clazz, jint nativeObject, jint flags, jint mask) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setFlags(flags, mask); if (err < 0 && err != NO_INIT) { @@ -242,7 +242,7 @@ static void nativeSetFlags(JNIEnv* env, jobject surfaceObj, jint nativeObject, j } } -static void nativeSetTransparentRegionHint(JNIEnv* env, jobject surfaceObj, jint nativeObject, jobject regionObj) { +static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jint nativeObject, jobject regionObj) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); SkRegion* region = android_graphics_Region_getSkRegion(env, regionObj); if (!region) { @@ -267,7 +267,7 @@ static void nativeSetTransparentRegionHint(JNIEnv* env, jobject surfaceObj, jint } } -static void nativeSetAlpha(JNIEnv* env, jobject surfaceObj, jint nativeObject, jfloat alpha) { +static void nativeSetAlpha(JNIEnv* env, jclass clazz, jint nativeObject, jfloat alpha) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setAlpha(alpha); if (err < 0 && err != NO_INIT) { @@ -275,7 +275,7 @@ static void nativeSetAlpha(JNIEnv* env, jobject surfaceObj, jint nativeObject, j } } -static void nativeSetMatrix(JNIEnv* env, jobject surfaceObj, jint nativeObject, +static void nativeSetMatrix(JNIEnv* env, jclass clazz, jint nativeObject, jfloat dsdx, jfloat dtdx, jfloat dsdy, jfloat dtdy) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setMatrix(dsdx, dtdx, dsdy, dtdy); @@ -284,7 +284,7 @@ static void nativeSetMatrix(JNIEnv* env, jobject surfaceObj, jint nativeObject, } } -static void nativeSetWindowCrop(JNIEnv* env, jobject surfaceObj, jint nativeObject, +static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jint nativeObject, jint l, jint t, jint r, jint b) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); Rect crop(l, t, r, b); @@ -294,7 +294,7 @@ static void nativeSetWindowCrop(JNIEnv* env, jobject surfaceObj, jint nativeObje } } -static void nativeSetLayerStack(JNIEnv* env, jobject surfaceObj, jint nativeObject, jint layerStack) { +static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jint nativeObject, jint layerStack) { SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); status_t err = ctrl->setLayerStack(layerStack); if (err < 0 && err != NO_INIT) { @@ -320,7 +320,7 @@ static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz, sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return; sp<Surface> sur(reinterpret_cast<Surface *>(nativeSurfaceObject)); - sp<IGraphicBufferProducer> bufferProducer(sur->getSurfaceTexture()); + sp<IGraphicBufferProducer> bufferProducer(sur->getIGraphicBufferProducer()); SurfaceComposerClient::setDisplaySurface(token, bufferProducer); } diff --git a/core/jni/android_view_TextureView.cpp b/core/jni/android_view_TextureView.cpp index 87b312f..e75a2d8 100644 --- a/core/jni/android_view_TextureView.cpp +++ b/core/jni/android_view_TextureView.cpp @@ -23,7 +23,7 @@ #include <ui/Rect.h> #include <gui/GLConsumer.h> -#include <gui/SurfaceTextureClient.h> +#include <gui/Surface.h> #include <SkBitmap.h> #include <SkCanvas.h> @@ -102,7 +102,7 @@ static void android_view_TextureView_createNativeWindow(JNIEnv* env, jobject tex jobject surface) { sp<GLConsumer> glConsumer(SurfaceTexture_getSurfaceTexture(env, surface)); - sp<ANativeWindow> window = new SurfaceTextureClient(glConsumer->getBufferQueue()); + sp<ANativeWindow> window = new Surface(glConsumer->getBufferQueue()); window->incStrong(0); SET_INT(textureView, gTextureViewClassInfo.nativeWindow, jint(window.get())); diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp index 199d5bf..37330ec 100644 --- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp +++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp @@ -28,7 +28,7 @@ #include <gui/Surface.h> #include <gui/GLConsumer.h> -#include <gui/SurfaceTextureClient.h> +#include <gui/Surface.h> #include <SkBitmap.h> #include <SkPixelRef.h> @@ -355,7 +355,7 @@ not_valid_surface: sp<GLConsumer> glConsumer(SurfaceTexture_getSurfaceTexture(_env, native_window)); - window = new SurfaceTextureClient(glConsumer->getBufferQueue()); + window = new Surface(glConsumer->getBufferQueue()); if (window == NULL) goto not_valid_surface; |