diff options
68 files changed, 709 insertions, 461 deletions
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp index 8ea28ec..e0abc24 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -478,7 +478,7 @@ static jobject nativeDecodeFileDescriptor(JNIEnv* env, jobject clazz, jobject fi NPE_CHECK_RETURN_ZERO(env, fileDescriptor); - jint descriptor = jniGetFDFromFileDescriptor(env, fileDescriptor); + int descriptor = jniGetFDFromFileDescriptor(env, fileDescriptor); struct stat fdStat; if (fstat(descriptor, &fdStat) == -1) { @@ -486,16 +486,27 @@ static jobject nativeDecodeFileDescriptor(JNIEnv* env, jobject clazz, jobject fi return nullObjectReturn("fstat return -1"); } - // Restore the descriptor's offset on exiting this function. + // Restore the descriptor's offset on exiting this function. Even though + // we dup the descriptor, both the original and dup refer to the same open + // file description and changes to the file offset in one impact the other. AutoFDSeek autoRestore(descriptor); - FILE* file = fdopen(descriptor, "r"); + // Duplicate the descriptor here to prevent leaking memory. A leak occurs + // if we only close the file descriptor and not the file object it is used to + // create. If we don't explicitly clean up the file (which in turn closes the + // descriptor) the buffers allocated internally by fseek will be leaked. + int dupDescriptor = dup(descriptor); + + FILE* file = fdopen(dupDescriptor, "r"); if (file == NULL) { + // cleanup the duplicated descriptor since it will not be closed when the + // file is cleaned up (fclose). + close(dupDescriptor); return nullObjectReturn("Could not open file"); } SkAutoTUnref<SkFILEStream> fileStream(new SkFILEStream(file, - SkFILEStream::kCallerRetains_Ownership)); + SkFILEStream::kCallerPasses_Ownership)); // Use a buffered stream. Although an SkFILEStream can be rewound, this // ensures that SkImageDecoder::Factory never rewinds beyond the diff --git a/core/jni/android/graphics/GraphicsJNI.h b/core/jni/android/graphics/GraphicsJNI.h index dcc97e5..e2b31cb 100644 --- a/core/jni/android/graphics/GraphicsJNI.h +++ b/core/jni/android/graphics/GraphicsJNI.h @@ -1,6 +1,8 @@ #ifndef GraphicsJNI_DEFINED #define GraphicsJNI_DEFINED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" #include "SkBitmap.h" #include "SkDevice.h" #include "SkPixelRef.h" @@ -8,6 +10,8 @@ #include "SkPoint.h" #include "SkRect.h" #include "SkImageDecoder.h" +#pragma GCC diagnostic pop + #include <jni.h> class SkBitmapRegionDecoder; diff --git a/core/jni/android_hardware_camera2_DngCreator.cpp b/core/jni/android_hardware_camera2_DngCreator.cpp index 31c7b9f..533313a 100644 --- a/core/jni/android_hardware_camera2_DngCreator.cpp +++ b/core/jni/android_hardware_camera2_DngCreator.cpp @@ -1278,7 +1278,7 @@ static void DngCreator_init(JNIEnv* env, jobject thiz, jobject characteristicsPt } BAIL_IF_INVALID(writer->addEntry(TAG_CAMERACALIBRATION2, entry2.count, - calibrationTransform1, TIFF_IFD_0), env, TAG_CAMERACALIBRATION2, writer); + calibrationTransform2, TIFF_IFD_0), env, TAG_CAMERACALIBRATION2, writer); } } diff --git a/core/jni/android_server_FingerprintManager.cpp b/core/jni/android_server_FingerprintManager.cpp index b174d1b..4e2d93e 100644 --- a/core/jni/android_server_FingerprintManager.cpp +++ b/core/jni/android_server_FingerprintManager.cpp @@ -184,7 +184,7 @@ static jint nativeCloseHal(JNIEnv* env, jobject clazz) { // TODO: clean up void methods static const JNINativeMethod g_methods[] = { { "nativeEnroll", "(I)I", (void*)nativeEnroll }, - { "nativeEnrollCancel", "()I", (void*)nativeEnroll }, + { "nativeEnrollCancel", "()I", (void*)nativeEnrollCancel }, { "nativeRemove", "(I)I", (void*)nativeRemove }, { "nativeOpenHal", "()I", (void*)nativeOpenHal }, { "nativeCloseHal", "()I", (void*)nativeCloseHal }, diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index 4859ee6..e104948 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -2084,7 +2084,7 @@ static JNINativeMethod gAssetManagerMethods[] = { { "getAssetAllocations", "()Ljava/lang/String;", (void*) android_content_AssetManager_getAssetAllocations }, { "getGlobalAssetManagerCount", "()I", - (void*) android_content_AssetManager_getGlobalAssetCount }, + (void*) android_content_AssetManager_getGlobalAssetManagerCount }, }; int register_android_content_AssetManager(JNIEnv* env) diff --git a/core/jni/android_util_FileObserver.cpp b/core/jni/android_util_FileObserver.cpp index 0327d8c..b906cfd 100644 --- a/core/jni/android_util_FileObserver.cpp +++ b/core/jni/android_util_FileObserver.cpp @@ -29,7 +29,7 @@ #include <sys/ioctl.h> #include <errno.h> -#ifdef HAVE_INOTIFY +#if defined(__linux__) #include <sys/inotify.h> #endif @@ -39,29 +39,25 @@ static jmethodID method_onEvent; static jint android_os_fileobserver_init(JNIEnv* env, jobject object) { -#ifdef HAVE_INOTIFY - - return (jint)inotify_init(); - -#else // HAVE_INOTIFY - +#if defined(__linux__) + return (jint)inotify_init(); +#else return -1; - -#endif // HAVE_INOTIFY +#endif } static void android_os_fileobserver_observe(JNIEnv* env, jobject object, jint fd) { -#ifdef HAVE_INOTIFY - +#if defined(__linux__) + char event_buf[512]; struct inotify_event* event; - + while (1) { int event_pos = 0; int num_bytes = read(fd, event_buf, sizeof(event_buf)); - + if (num_bytes < (int)sizeof(*event)) { if (errno == EINTR) @@ -70,14 +66,14 @@ static void android_os_fileobserver_observe(JNIEnv* env, jobject object, jint fd ALOGE("***** ERROR! android_os_fileobserver_observe() got a short event!"); return; } - + while (num_bytes >= (int)sizeof(*event)) { int event_size; event = (struct inotify_event *)(event_buf + event_pos); jstring path = NULL; - + if (event->len > 0) { path = env->NewStringUTF(event->name); @@ -98,37 +94,37 @@ static void android_os_fileobserver_observe(JNIEnv* env, jobject object, jint fd event_pos += event_size; } } - -#endif // HAVE_INOTIFY + +#endif } static jint android_os_fileobserver_startWatching(JNIEnv* env, jobject object, jint fd, jstring pathString, jint mask) { int res = -1; - -#ifdef HAVE_INOTIFY - + +#if defined(__linux__) + if (fd >= 0) { const char* path = env->GetStringUTFChars(pathString, NULL); - + res = inotify_add_watch(fd, path, mask); - + env->ReleaseStringUTFChars(pathString, path); } -#endif // HAVE_INOTIFY - +#endif + return res; } static void android_os_fileobserver_stopWatching(JNIEnv* env, jobject object, jint fd, jint wfd) { -#ifdef HAVE_INOTIFY +#if defined(__linux__) inotify_rm_watch((int)fd, (uint32_t)wfd); -#endif // HAVE_INOTIFY +#endif } static JNINativeMethod sMethods[] = { @@ -137,7 +133,7 @@ static JNINativeMethod sMethods[] = { { "observe", "(I)V", (void*)android_os_fileobserver_observe }, { "startWatching", "(ILjava/lang/String;I)I", (void*)android_os_fileobserver_startWatching }, { "stopWatching", "(II)V", (void*)android_os_fileobserver_stopWatching } - + }; int register_android_os_FileObserver(JNIEnv* env) diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp index 6506190..2b0960f 100644 --- a/core/jni/android_util_Process.cpp +++ b/core/jni/android_util_Process.cpp @@ -287,7 +287,8 @@ static void android_os_Process_setCanSelfBackground(JNIEnv* env, jobject clazz, void android_os_Process_setThreadScheduler(JNIEnv* env, jclass clazz, jint tid, jint policy, jint pri) { -#ifdef HAVE_SCHED_SETSCHEDULER +// linux has sched_setscheduler(), others don't. +#if defined(__linux__) struct sched_param param; param.sched_priority = pri; int rc = sched_setscheduler(tid, policy, ¶m); diff --git a/core/tests/coretests/src/android/text/TextUtilsTest.java b/core/tests/coretests/src/android/text/TextUtilsTest.java index d494c5d..5a6ef30 100644 --- a/core/tests/coretests/src/android/text/TextUtilsTest.java +++ b/core/tests/coretests/src/android/text/TextUtilsTest.java @@ -353,6 +353,7 @@ public class TextUtilsTest extends TestCase { assertNull("null CharSequence should generate null from parcel", text); p = Parcel.obtain(); TextUtils.writeToParcel("test", p, 0); + p.setDataPosition(0); text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p); assertEquals("conversion to/from parcel failed", "test", text); } diff --git a/drm/jni/Android.mk b/drm/jni/Android.mk index 474b9b2..08c7b95 100644 --- a/drm/jni/Android.mk +++ b/drm/jni/Android.mk @@ -39,8 +39,8 @@ LOCAL_C_INCLUDES += \ $(TOP)/frameworks/av/include \ $(TOP)/libcore/include - - LOCAL_MODULE_TAGS := optional +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_SHARED_LIBRARY) diff --git a/drm/jni/android_drm_DrmManagerClient.cpp b/drm/jni/android_drm_DrmManagerClient.cpp index d321baf..52597e1 100644 --- a/drm/jni/android_drm_DrmManagerClient.cpp +++ b/drm/jni/android_drm_DrmManagerClient.cpp @@ -381,7 +381,8 @@ static jobjectArray android_drm_DrmManagerClient_getAllSupportInfo( } static void android_drm_DrmManagerClient_installDrmEngine( - JNIEnv* env, jobject thiz, jint uniqueId, jstring engineFilePath) { + JNIEnv* /* env */, jobject /* thiz */, jint /* uniqueId */, + jstring /* engineFilePath */) { ALOGV("installDrmEngine - Enter"); //getDrmManagerClient(env, thiz) // ->installDrmEngine(uniqueId, Utility::getStringValue(env, engineFilePath)); @@ -776,7 +777,7 @@ static int registerNativeMethods(JNIEnv* env) { return result; } -jint JNI_OnLoad(JavaVM* vm, void* reserved) { +jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) { JNIEnv* env = NULL; jint result = -1; diff --git a/libs/androidfw/BackupHelpers.cpp b/libs/androidfw/BackupHelpers.cpp index c78593d..3f82830 100644 --- a/libs/androidfw/BackupHelpers.cpp +++ b/libs/androidfw/BackupHelpers.cpp @@ -1307,23 +1307,12 @@ get_mod_time(const char* filename, struct timeval times[2]) fprintf(stderr, "stat '%s' failed: %s\n", filename, strerror(errno)); return errno; } - times[0].tv_sec = st.st_atime; - times[1].tv_sec = st.st_mtime; - - // If st_atime is a macro then struct stat64 uses struct timespec - // to store the access and modif time values and typically - // st_*time_nsec is not defined. In glibc, this is controlled by - // __USE_MISC. -#ifdef __USE_MISC -#if !defined(st_atime) || defined(st_atime_nsec) -#error "Check if this __USE_MISC conditional is still needed." -#endif + + times[0].tv_sec = st.st_atim.tv_sec; times[0].tv_usec = st.st_atim.tv_nsec / 1000; + + times[1].tv_sec = st.st_mtim.tv_sec; times[1].tv_usec = st.st_mtim.tv_nsec / 1000; -#else - times[0].tv_usec = st.st_atime_nsec / 1000; - times[1].tv_usec = st.st_mtime_nsec / 1000; -#endif return 0; } diff --git a/libs/hwui/AmbientShadow.cpp b/libs/hwui/AmbientShadow.cpp index cb3a002..2d1cf78 100644 --- a/libs/hwui/AmbientShadow.cpp +++ b/libs/hwui/AmbientShadow.cpp @@ -121,7 +121,7 @@ inline void computeBufferSize(int* totalVertexCount, int* totalIndexCount, *totalUmbraCount = 0; if (!isCasterOpaque) { // Add the centroid if occluder is translucent. - *totalVertexCount++; + (*totalVertexCount)++; *totalIndexCount += 2 * innerVertexCount + 1; *totalUmbraCount = innerVertexCount; } diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk index 5b74add..a09355b 100644 --- a/libs/hwui/Android.mk +++ b/libs/hwui/Android.mk @@ -13,107 +13,110 @@ LOCAL_CLANG_CFLAGS += \ # Only build libhwui when USE_OPENGL_RENDERER is # defined in the current device/board configuration ifeq ($(USE_OPENGL_RENDERER),true) - LOCAL_SRC_FILES := \ - utils/Blur.cpp \ - utils/GLUtils.cpp \ - utils/SortedListImpl.cpp \ - thread/TaskManager.cpp \ - font/CacheTexture.cpp \ - font/Font.cpp \ - AmbientShadow.cpp \ - AnimationContext.cpp \ - Animator.cpp \ - AnimatorManager.cpp \ - AssetAtlas.cpp \ - DamageAccumulator.cpp \ - FontRenderer.cpp \ - GammaFontRenderer.cpp \ - Caches.cpp \ - DisplayList.cpp \ - DeferredDisplayList.cpp \ - DeferredLayerUpdater.cpp \ - DisplayListLogBuffer.cpp \ - DisplayListRenderer.cpp \ - Dither.cpp \ - DrawProfiler.cpp \ - Extensions.cpp \ - FboCache.cpp \ - GradientCache.cpp \ - Image.cpp \ - Interpolator.cpp \ - Layer.cpp \ - LayerCache.cpp \ - LayerRenderer.cpp \ - Matrix.cpp \ - OpenGLRenderer.cpp \ - Patch.cpp \ - PatchCache.cpp \ - PathCache.cpp \ - PathTessellator.cpp \ - PixelBuffer.cpp \ - Program.cpp \ - ProgramCache.cpp \ - RenderBufferCache.cpp \ - RenderNode.cpp \ - RenderProperties.cpp \ - RenderState.cpp \ - ResourceCache.cpp \ - ShadowTessellator.cpp \ - SkiaShader.cpp \ - Snapshot.cpp \ - SpotShadow.cpp \ - StatefulBaseRenderer.cpp \ - Stencil.cpp \ - TessellationCache.cpp \ - Texture.cpp \ - TextureCache.cpp \ - TextDropShadowCache.cpp + LOCAL_SRC_FILES := \ + utils/Blur.cpp \ + utils/GLUtils.cpp \ + utils/SortedListImpl.cpp \ + thread/TaskManager.cpp \ + font/CacheTexture.cpp \ + font/Font.cpp \ + AmbientShadow.cpp \ + AnimationContext.cpp \ + Animator.cpp \ + AnimatorManager.cpp \ + AssetAtlas.cpp \ + DamageAccumulator.cpp \ + FontRenderer.cpp \ + GammaFontRenderer.cpp \ + Caches.cpp \ + DisplayList.cpp \ + DeferredDisplayList.cpp \ + DeferredLayerUpdater.cpp \ + DisplayListLogBuffer.cpp \ + DisplayListRenderer.cpp \ + Dither.cpp \ + DrawProfiler.cpp \ + Extensions.cpp \ + FboCache.cpp \ + GradientCache.cpp \ + Image.cpp \ + Interpolator.cpp \ + Layer.cpp \ + LayerCache.cpp \ + LayerRenderer.cpp \ + Matrix.cpp \ + OpenGLRenderer.cpp \ + Patch.cpp \ + PatchCache.cpp \ + PathCache.cpp \ + PathTessellator.cpp \ + PixelBuffer.cpp \ + Program.cpp \ + ProgramCache.cpp \ + RenderBufferCache.cpp \ + RenderNode.cpp \ + RenderProperties.cpp \ + RenderState.cpp \ + ResourceCache.cpp \ + ShadowTessellator.cpp \ + SkiaShader.cpp \ + Snapshot.cpp \ + SpotShadow.cpp \ + StatefulBaseRenderer.cpp \ + Stencil.cpp \ + TessellationCache.cpp \ + Texture.cpp \ + TextureCache.cpp \ + TextDropShadowCache.cpp # RenderThread stuff - LOCAL_SRC_FILES += \ - renderthread/CanvasContext.cpp \ - renderthread/DrawFrameTask.cpp \ - renderthread/EglManager.cpp \ - renderthread/RenderProxy.cpp \ - renderthread/RenderTask.cpp \ - renderthread/RenderThread.cpp \ - renderthread/TimeLord.cpp + LOCAL_SRC_FILES += \ + renderthread/CanvasContext.cpp \ + renderthread/DrawFrameTask.cpp \ + renderthread/EglManager.cpp \ + renderthread/RenderProxy.cpp \ + renderthread/RenderTask.cpp \ + renderthread/RenderThread.cpp \ + renderthread/TimeLord.cpp - intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,) + intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,) - LOCAL_C_INCLUDES += \ - external/skia/src/core + LOCAL_C_INCLUDES += \ + external/skia/src/core - LOCAL_CFLAGS += -DUSE_OPENGL_RENDERER -DEGL_EGLEXT_PROTOTYPES -DGL_GLEXT_PROTOTYPES - LOCAL_CFLAGS += -Wno-unused-parameter - LOCAL_MODULE_CLASS := SHARED_LIBRARIES - LOCAL_SHARED_LIBRARIES := liblog libcutils libutils libEGL libGLESv2 libskia libui libgui - LOCAL_MODULE := libhwui - LOCAL_MODULE_TAGS := optional + LOCAL_CFLAGS += -DUSE_OPENGL_RENDERER -DEGL_EGLEXT_PROTOTYPES -DGL_GLEXT_PROTOTYPES + LOCAL_CFLAGS += -Wno-unused-parameter + LOCAL_MODULE_CLASS := SHARED_LIBRARIES + LOCAL_SHARED_LIBRARIES := liblog libcutils libutils libEGL libGLESv2 libskia libui libgui + LOCAL_MODULE := libhwui + LOCAL_MODULE_TAGS := optional - ifneq (false,$(ANDROID_ENABLE_RENDERSCRIPT)) - LOCAL_CFLAGS += -DANDROID_ENABLE_RENDERSCRIPT - LOCAL_SHARED_LIBRARIES += libRS libRScpp - LOCAL_C_INCLUDES += \ - $(intermediates) \ - frameworks/rs/cpp \ - frameworks/rs \ + ifneq (false,$(ANDROID_ENABLE_RENDERSCRIPT)) + LOCAL_CFLAGS += -DANDROID_ENABLE_RENDERSCRIPT + LOCAL_SHARED_LIBRARIES += libRS libRScpp + LOCAL_C_INCLUDES += \ + $(intermediates) \ + frameworks/rs/cpp \ + frameworks/rs \ - endif + endif - ifndef HWUI_COMPILE_SYMBOLS - LOCAL_CFLAGS += -fvisibility=hidden - endif + ifndef HWUI_COMPILE_SYMBOLS + LOCAL_CFLAGS += -fvisibility=hidden + endif - ifdef HWUI_COMPILE_FOR_PERF - LOCAL_CFLAGS += -fno-omit-frame-pointer -marm -mapcs - endif + ifdef HWUI_COMPILE_FOR_PERF + # TODO: Non-arm? + LOCAL_CFLAGS += -fno-omit-frame-pointer -marm -mapcs + endif - # Defaults for ATRACE_TAG and LOG_TAG for libhwui - LOCAL_CFLAGS += -DATRACE_TAG=ATRACE_TAG_VIEW -DLOG_TAG=\"OpenGLRenderer\" + # Defaults for ATRACE_TAG and LOG_TAG for libhwui + LOCAL_CFLAGS += -DATRACE_TAG=ATRACE_TAG_VIEW -DLOG_TAG=\"OpenGLRenderer\" - include external/stlport/libstlport.mk - include $(BUILD_SHARED_LIBRARY) + LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code - include $(call all-makefiles-under,$(LOCAL_PATH)) + include external/stlport/libstlport.mk + include $(BUILD_SHARED_LIBRARY) + + include $(call all-makefiles-under,$(LOCAL_PATH)) endif diff --git a/libs/hwui/DeferredDisplayList.cpp b/libs/hwui/DeferredDisplayList.cpp index a998594..fbe2d39 100644 --- a/libs/hwui/DeferredDisplayList.cpp +++ b/libs/hwui/DeferredDisplayList.cpp @@ -333,7 +333,7 @@ private: class RestoreToCountBatch : public Batch { public: RestoreToCountBatch(const StateOp* op, const DeferredDisplayState* state, int restoreCount) : - mOp(op), mState(state), mRestoreCount(restoreCount) {} + mState(state), mRestoreCount(restoreCount) {} virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty, int index) { DEFER_LOGD("batch %p restoring to count %d", this, mRestoreCount); @@ -345,7 +345,6 @@ public: private: // we use the state storage for the RestoreToCountOp, but don't replay the op itself - const StateOp* mOp; const DeferredDisplayState* mState; /* @@ -700,7 +699,6 @@ void DeferredDisplayList::discardDrawingBatches(const unsigned int maxIndex) { for (unsigned int i = mEarliestUnclearedIndex; i <= maxIndex; i++) { // leave deferred state ops alone for simplicity (empty save restore pairs may now exist) if (mBatches[i] && mBatches[i]->purelyDrawBatch()) { - DrawBatch* b = (DrawBatch*) mBatches[i]; delete mBatches[i]; mBatches.replaceAt(NULL, i); } diff --git a/libs/hwui/DeferredDisplayList.h b/libs/hwui/DeferredDisplayList.h index 8a015b2..f7f30b1 100644 --- a/libs/hwui/DeferredDisplayList.h +++ b/libs/hwui/DeferredDisplayList.h @@ -79,7 +79,7 @@ public: }; class DeferredDisplayList { - friend class DeferStateStruct; // used to give access to allocator + friend struct DeferStateStruct; // used to give access to allocator public: DeferredDisplayList(const Rect& bounds, bool avoidOverdraw = true) : mBounds(bounds), mAvoidOverdraw(avoidOverdraw) { diff --git a/libs/hwui/DisplayList.h b/libs/hwui/DisplayList.h index dea109c..657632d 100644 --- a/libs/hwui/DisplayList.h +++ b/libs/hwui/DisplayList.h @@ -91,8 +91,7 @@ private: std::vector<SkPath> mTempPaths; }; -class DeferStateStruct : public PlaybackStateStruct { -public: +struct DeferStateStruct : public PlaybackStateStruct { DeferStateStruct(DeferredDisplayList& deferredList, OpenGLRenderer& renderer, int replayFlags) : PlaybackStateStruct(renderer, replayFlags, &(deferredList.mAllocator)), mDeferredList(deferredList) {} diff --git a/libs/hwui/DisplayListLogBuffer.cpp b/libs/hwui/DisplayListLogBuffer.cpp index 45aacca..bc9e7bd 100644 --- a/libs/hwui/DisplayListLogBuffer.cpp +++ b/libs/hwui/DisplayListLogBuffer.cpp @@ -80,7 +80,7 @@ void DisplayListLogBuffer::outputCommands(FILE *file) fprintf(file, "%*s%s\n", 2 * tmpBufferPtr->level, "", tmpBufferPtr->label); - OpLog* nextOp = tmpBufferPtr++; + tmpBufferPtr++; if (tmpBufferPtr > mBufferLast) { tmpBufferPtr = mBufferFirst; } diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index 3910381..5b5b098 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -358,7 +358,7 @@ void FontRenderer::cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyp break; } case SkMask::kBW_Format: { - uint32_t cacheX = 0, bX = 0, cacheY = 0, bY = 0; + uint32_t cacheX = 0, cacheY = 0; uint32_t row = (startY - TEXTURE_BORDER_SIZE) * cacheWidth + startX - TEXTURE_BORDER_SIZE; static const uint8_t COLORS[2] = { 0, 255 }; diff --git a/libs/hwui/Interpolator.cpp b/libs/hwui/Interpolator.cpp index ff8ff73..0e62d77 100644 --- a/libs/hwui/Interpolator.cpp +++ b/libs/hwui/Interpolator.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// LOG_TAG is being provided by the Makefile, reset. +#ifdef LOG_TAG +#undef LOG_TAG +#endif #define LOG_TAG "Interpolator" #include "Interpolator.h" diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp index 833f64b..cb7a350 100644 --- a/libs/hwui/LayerCache.cpp +++ b/libs/hwui/LayerCache.cpp @@ -80,8 +80,10 @@ int LayerCache::LayerEntry::compare(const LayerCache::LayerEntry& lhs, void LayerCache::deleteLayer(Layer* layer) { if (layer) { - LAYER_LOGD("Destroying layer %dx%d, fbo %d", layer->getWidth(), layer->getHeight(), - layer->getFbo()); + if (kDebugLayers) { + ALOGD("Destroying layer %dx%d, fbo %d", layer->getWidth(), layer->getHeight(), + layer->getFbo()); + } mSize -= layer->getWidth() * layer->getHeight() * 4; layer->state = Layer::kState_DeletedFromCache; Caches::getInstance().resourceCache.decrementRefcount(layer); @@ -110,9 +112,13 @@ Layer* LayerCache::get(RenderState& renderState, const uint32_t width, const uin layer->state = Layer::kState_RemovedFromCache; mSize -= layer->getWidth() * layer->getHeight() * 4; - LAYER_LOGD("Reusing layer %dx%d", layer->getWidth(), layer->getHeight()); + if (kDebugLayers) { + ALOGD("Reusing layer %dx%d", layer->getWidth(), layer->getHeight()); + } } else { - LAYER_LOGD("Creating new layer %dx%d", entry.mWidth, entry.mHeight); + if (kDebugLayers) { + ALOGD("Creating new layer %dx%d", entry.mWidth, entry.mHeight); + } layer = new Layer(Layer::kType_DisplayList, renderState, entry.mWidth, entry.mHeight); layer->setBlend(true); @@ -137,7 +143,9 @@ void LayerCache::dump() { size_t size = mCache.size(); for (size_t i = 0; i < size; i++) { const LayerEntry& entry = mCache.itemAt(i); - LAYER_LOGD(" Layer size %dx%d", entry.mWidth, entry.mHeight); + if (kDebugLayers) { + ALOGD(" Layer size %dx%d", entry.mWidth, entry.mHeight); + } } } @@ -157,8 +165,10 @@ bool LayerCache::put(Layer* layer) { deleteLayer(victim); mCache.removeAt(position); - LAYER_LOGD(" Deleting layer %.2fx%.2f", victim->layer.getWidth(), - victim->layer.getHeight()); + if (kDebugLayers) { + ALOGD(" Deleting layer %.2fx%.2f", victim->layer.getWidth(), + victim->layer.getHeight()); + } } layer->cancelDefer(); diff --git a/libs/hwui/LayerCache.h b/libs/hwui/LayerCache.h index 6b93e8f..81810ac 100644 --- a/libs/hwui/LayerCache.h +++ b/libs/hwui/LayerCache.h @@ -26,15 +26,11 @@ namespace uirenderer { class RenderState; -/////////////////////////////////////////////////////////////////////////////// -// Defines -/////////////////////////////////////////////////////////////////////////////// - // Debug #if DEBUG_LAYERS - #define LAYER_LOGD(...) ALOGD(__VA_ARGS__) +static const bool kDebugLayers = true; #else - #define LAYER_LOGD(...) +static const bool kDebugLayers = false; #endif /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index ce1d09f..40a58f2 100755 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -473,8 +473,6 @@ bool OpenGLRenderer::updateLayer(Layer* layer, bool inFrame) { && layer->renderNode.get() && layer->renderNode->isRenderable()) { ATRACE_CALL(); - Rect& dirty = layer->dirtyRect; - if (inFrame) { endTiling(); debugOverdraw(false, false); @@ -779,8 +777,10 @@ int OpenGLRenderer::saveLayerDeferred(float left, float top, float right, float */ bool OpenGLRenderer::createLayer(float left, float top, float right, float bottom, const SkPaint* paint, int flags, const SkPath* convexMask) { - LAYER_LOGD("Requesting layer %.2fx%.2f", right - left, bottom - top); - LAYER_LOGD("Layer cache size = %d", mCaches.layerCache.getSize()); + if (kDebugLayers) { + ALOGD("Requesting layer %.2fx%.2f", right - left, bottom - top); + ALOGD("Layer cache size = %d", mCaches.layerCache.getSize()); + } const bool fboLayer = flags & SkCanvas::kClipToLayer_SaveFlag; @@ -955,7 +955,9 @@ void OpenGLRenderer::composeLayer(const Snapshot& removed, const Snapshot& resto // Failing to add the layer to the cache should happen only if the layer is too large layer->setConvexMask(NULL); if (!mCaches.layerCache.put(layer)) { - LAYER_LOGD("Deleting layer"); + if (kDebugLayers) { + ALOGD("Deleting layer"); + } Caches::getInstance().resourceCache.decrementRefcount(layer); } } @@ -1984,8 +1986,6 @@ status_t OpenGLRenderer::drawRenderNode(RenderNode* renderNode, Rect& dirty, int } void OpenGLRenderer::drawAlphaBitmap(Texture* texture, float left, float top, const SkPaint* paint) { - int color = paint != NULL ? paint->getColor() : 0; - float x = left; float y = top; @@ -2407,7 +2407,7 @@ status_t OpenGLRenderer::drawVertexBuffer(float translateX, float translateY, setupDrawShaderUniforms(getShader(paint)); const void* vertices = vertexBuffer.getBuffer(); - bool force = mCaches.unbindMeshBuffer(); + mCaches.unbindMeshBuffer(); mCaches.bindPositionVertexPointer(true, vertices, isAA ? gAlphaVertexStride : gVertexStride); mCaches.resetTexCoordsVertexPointer(); @@ -3182,14 +3182,6 @@ status_t OpenGLRenderer::drawRects(const float* rects, int count, const SkPaint* return drawColorRects(rects, count, paint, false, true, true); } -static void mapPointFakeZ(Vector3& point, const mat4& transformXY, const mat4& transformZ) { - // map z coordinate with true 3d matrix - point.z = transformZ.mapZ(point); - - // map x,y coordinates with draw/Skia matrix - transformXY.mapPoint(point.x, point.y); -} - status_t OpenGLRenderer::drawShadow(float casterAlpha, const VertexBuffer* ambientShadowVertexBuffer, const VertexBuffer* spotShadowVertexBuffer) { if (currentSnapshot()->isIgnored()) return DrawGlInfo::kStatusDone; diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp index 9ba8854..a3d7019 100644 --- a/libs/hwui/PathCache.cpp +++ b/libs/hwui/PathCache.cpp @@ -212,7 +212,7 @@ void PathCache::removeTexture(PathTexture* texture) { // before attempting our cleanup const sp<Task<SkBitmap*> >& task = texture->task(); if (task != NULL) { - SkBitmap* bitmap = task->getResult(); + task->getResult(); texture->clearTask(); } else { // If there is a pending task, the path was not added diff --git a/libs/hwui/PathTessellator.cpp b/libs/hwui/PathTessellator.cpp index 281ca02..d842ed5 100644 --- a/libs/hwui/PathTessellator.cpp +++ b/libs/hwui/PathTessellator.cpp @@ -279,7 +279,6 @@ void getStrokeVerticesFromUnclosedVertices(const PaintInfo& paintInfo, - (vertices[lastIndex].x - vertices[lastIndex - 1].x), vertices[lastIndex].y - vertices[lastIndex - 1].y); const float dTheta = PI / (extra + 1); - const float radialScale = 2.0f / (1 + cos(dTheta)); int capOffset; for (int i = 0; i < extra; i++) { @@ -831,7 +830,6 @@ void PathTessellator::tessellatePoints(const float* points, int count, const SkP Rect bounds; // tessellate, then duplicate outline across points - int numPoints = count / 2; VertexBuffer tempBuffer; if (!paintInfo.isAA) { getFillVerticesFromPerimeter(outlineVertices, tempBuffer); diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h index 7eb9a32..8d529c6 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -244,7 +244,7 @@ enum DebugLevel { // Converts a number of kilo-bytes into bytes #define KB(s) s * 1024 -static DebugLevel readDebugLevel() { +static inline DebugLevel readDebugLevel() { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_DEBUG, property, NULL) > 0) { return (DebugLevel) atoi(property); diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index 254492f..22808e2 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -736,7 +736,6 @@ void RenderNode::issueOperationsOf3dChildren(ChildrenSelectMode mode, int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag); DrawRenderNodeOp* childOp = zTranslatedNodes[drawIndex].value; - RenderNode* child = childOp->mRenderNode; renderer.concatMatrix(childOp->mTransformFromParent); childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone @@ -885,7 +884,7 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) { initialTransform, zTranslatedNodes, renderer, handler); - for (int opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) { + for (size_t opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) { DisplayListOp *op = mDisplayListData->displayListOps[opIndex]; #if DEBUG_DISPLAY_LIST op->output(level + 1); @@ -893,7 +892,8 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) { logBuffer.writeCommand(level, op->name()); handler(op, saveCountOffset, properties().getClipToBounds()); - if (CC_UNLIKELY(!mProjectedNodes.isEmpty() && opIndex == projectionReceiveIndex)) { + if (CC_UNLIKELY(!mProjectedNodes.isEmpty() && projectionReceiveIndex >= 0 && + opIndex == static_cast<size_t>(projectionReceiveIndex))) { issueOperationsOfProjectedChildren(renderer, handler); } } diff --git a/libs/hwui/ShadowTessellator.cpp b/libs/hwui/ShadowTessellator.cpp index c1ffa0a..93d4b31 100644 --- a/libs/hwui/ShadowTessellator.cpp +++ b/libs/hwui/ShadowTessellator.cpp @@ -87,7 +87,6 @@ void ShadowTessellator::tessellateSpotShadow(bool isCasterOpaque, reverseReceiverTransform.loadInverse(receiverTransform); reverseReceiverTransform.mapPoint3d(adjustedLightCenter); - const int lightVertexCount = 8; if (CC_UNLIKELY(caches.propertyLightDiameter > 0)) { lightRadius = caches.propertyLightDiameter; } diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp index ba878ba..bf55558 100644 --- a/libs/hwui/font/Font.cpp +++ b/libs/hwui/font/Font.cpp @@ -378,7 +378,7 @@ void Font::precache(const SkPaint* paint, const char* text, int numGlyphs) { break; } - CachedGlyphInfo* cachedGlyph = getCachedGlyph(paint, glyph, true); + getCachedGlyph(paint, glyph, true); glyphsCount++; } } @@ -403,8 +403,6 @@ void Font::render(const SkPaint* paint, const char* text, uint32_t start, uint32 text += start; int glyphsCount = 0; - const SkPaint::Align align = paint->getTextAlign(); - while (glyphsCount < numGlyphs) { glyph_t glyph = GET_GLYPH(text); diff --git a/libs/hwui/font/FontUtil.h b/libs/hwui/font/FontUtil.h index c2fd5f5..4e5debe 100644 --- a/libs/hwui/font/FontUtil.h +++ b/libs/hwui/font/FontUtil.h @@ -30,9 +30,12 @@ #define DEFAULT_TEXT_LARGE_CACHE_WIDTH 2048 #define DEFAULT_TEXT_LARGE_CACHE_HEIGHT 512 -#define TEXTURE_BORDER_SIZE 1 -#if TEXTURE_BORDER_SIZE != 1 -# error TEXTURE_BORDER_SIZE other than 1 is not currently supported +#ifdef TEXTURE_BORDER_SIZE + #if TEXTURE_BORDER_SIZE != 1 + #error TEXTURE_BORDER_SIZE other than 1 is not currently supported + #endif +#else + #define TEXTURE_BORDER_SIZE 1 #endif #define CACHE_BLOCK_ROUNDING_SIZE 4 @@ -44,7 +47,7 @@ #define GET_GLYPH(text) nextGlyph((const uint16_t**) &text) #define IS_END_OF_STRING(glyph) false - static glyph_t nextGlyph(const uint16_t** srcPtr) { + static inline glyph_t nextGlyph(const uint16_t** srcPtr) { const uint16_t* src = *srcPtr; glyph_t g = *src++; *srcPtr = src; diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp index 047819d..c6ea82b 100644 --- a/libs/hwui/renderthread/RenderProxy.cpp +++ b/libs/hwui/renderthread/RenderProxy.cpp @@ -349,8 +349,12 @@ CREATE_BRIDGE0(fence) { return NULL; } +template <typename T> +void UNUSED(T t) {} + void RenderProxy::fence() { SETUP_TASK(fence); + UNUSED(args); postAndWait(task); } diff --git a/libs/hwui/renderthread/RenderTask.cpp b/libs/hwui/renderthread/RenderTask.cpp index 7ca61e4..13970ba 100644 --- a/libs/hwui/renderthread/RenderTask.cpp +++ b/libs/hwui/renderthread/RenderTask.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// LOG_TAG is being provided by the Makefile, reset. +#ifdef LOG_TAG +#undef LOG_TAG +#endif #define LOG_TAG "RenderTask" #include "RenderTask.h" diff --git a/libs/input/Android.mk b/libs/input/Android.mk index a7fb0e2..2bbfdcc 100644 --- a/libs/input/Android.mk +++ b/libs/input/Android.mk @@ -27,14 +27,14 @@ LOCAL_SHARED_LIBRARIES := \ libskia \ libgui \ libui \ - libinput \ - libinputflinger + libinput \ + libinputflinger LOCAL_C_INCLUDES := \ frameworks/native/services -LOCAL_CFLAGS += -Wno-unused-parameter +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code LOCAL_MODULE:= libinputservice diff --git a/libs/input/PointerController.cpp b/libs/input/PointerController.cpp index 9af521b..1152737 100644 --- a/libs/input/PointerController.cpp +++ b/libs/input/PointerController.cpp @@ -25,11 +25,14 @@ #include <cutils/log.h> +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" #include <SkBitmap.h> #include <SkCanvas.h> #include <SkColor.h> #include <SkPaint.h> #include <SkXfermode.h> +#pragma GCC diagnostic pop namespace android { diff --git a/libs/input/SpriteController.cpp b/libs/input/SpriteController.cpp index 5391393..0bc832a 100644 --- a/libs/input/SpriteController.cpp +++ b/libs/input/SpriteController.cpp @@ -24,11 +24,15 @@ #include <utils/String8.h> #include <gui/Surface.h> +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" #include <SkBitmap.h> #include <SkCanvas.h> #include <SkColor.h> #include <SkPaint.h> #include <SkXfermode.h> +#pragma GCC diagnostic pop + #include <android/native_window.h> namespace android { diff --git a/media/jni/Android.mk b/media/jni/Android.mk index 90fe695..4ebbe26 100644 --- a/media/jni/Android.mk +++ b/media/jni/Android.mk @@ -64,7 +64,7 @@ LOCAL_C_INCLUDES += \ $(PV_INCLUDES) \ $(JNI_H_INCLUDE) -LOCAL_CFLAGS += +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code LOCAL_MODULE:= libmedia_jni diff --git a/media/jni/android_media_AmrInputStream.cpp b/media/jni/android_media_AmrInputStream.cpp index 3df6530..afb5d5c 100644 --- a/media/jni/android_media_AmrInputStream.cpp +++ b/media/jni/android_media_AmrInputStream.cpp @@ -50,7 +50,7 @@ struct GsmAmrEncoderState { }; static jlong android_media_AmrInputStream_GsmAmrEncoderNew - (JNIEnv *env, jclass clazz) { + (JNIEnv *env, jclass /* clazz */) { GsmAmrEncoderState* gae = new GsmAmrEncoderState(); if (gae == NULL) { jniThrowRuntimeException(env, "Out of memory"); @@ -59,7 +59,7 @@ static jlong android_media_AmrInputStream_GsmAmrEncoderNew } static void android_media_AmrInputStream_GsmAmrEncoderInitialize - (JNIEnv *env, jclass clazz, jlong gae) { + (JNIEnv *env, jclass /* clazz */, jlong gae) { GsmAmrEncoderState *state = (GsmAmrEncoderState *) gae; int32_t nResult = AMREncodeInit(&state->mEncState, &state->mSidState, false); if (nResult != OK) { @@ -69,7 +69,7 @@ static void android_media_AmrInputStream_GsmAmrEncoderInitialize } static jint android_media_AmrInputStream_GsmAmrEncoderEncode - (JNIEnv *env, jclass clazz, + (JNIEnv *env, jclass /* clazz */, jlong gae, jbyteArray pcm, jint pcmOffset, jbyteArray amr, jint amrOffset) { jbyte inBuf[BYTES_PER_FRAME]; @@ -105,7 +105,7 @@ static jint android_media_AmrInputStream_GsmAmrEncoderEncode } static void android_media_AmrInputStream_GsmAmrEncoderCleanup - (JNIEnv *env, jclass clazz, jlong gae) { + (JNIEnv* /* env */, jclass /* clazz */, jlong gae) { GsmAmrEncoderState *state = (GsmAmrEncoderState *) gae; AMREncodeExit(&state->mEncState, &state->mSidState); state->mEncState = NULL; @@ -113,7 +113,7 @@ static void android_media_AmrInputStream_GsmAmrEncoderCleanup } static void android_media_AmrInputStream_GsmAmrEncoderDelete - (JNIEnv *env, jclass clazz, jlong gae) { + (JNIEnv* /* env */, jclass /* clazz */, jlong gae) { delete (GsmAmrEncoderState*)gae; } diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp index aaff9a2..45377ad 100644 --- a/media/jni/android_media_ImageReader.cpp +++ b/media/jni/android_media_ImageReader.cpp @@ -502,7 +502,6 @@ static jint Image_imageGetPixelStride(JNIEnv* env, CpuConsumer::LockedBuffer* bu case HAL_PIXEL_FORMAT_Y8: // Single plane 8bpp data. ALOG_ASSERT(idx == 0, "Wrong index: %d", idx); - pixelStride; break; case HAL_PIXEL_FORMAT_YV12: pixelStride = 1; diff --git a/media/jni/android_media_MediaCodecList.cpp b/media/jni/android_media_MediaCodecList.cpp index 12eb7d2..f8c349b 100644 --- a/media/jni/android_media_MediaCodecList.cpp +++ b/media/jni/android_media_MediaCodecList.cpp @@ -42,7 +42,7 @@ static sp<IMediaCodecList> getCodecList(JNIEnv *env) { } static jint android_media_MediaCodecList_getCodecCount( - JNIEnv *env, jobject thiz) { + JNIEnv *env, jobject /* thiz */) { sp<IMediaCodecList> mcl = getCodecList(env); if (mcl == NULL) { // Runtime exception already pending. @@ -52,7 +52,7 @@ static jint android_media_MediaCodecList_getCodecCount( } static jstring android_media_MediaCodecList_getCodecName( - JNIEnv *env, jobject thiz, jint index) { + JNIEnv *env, jobject /* thiz */, jint index) { sp<IMediaCodecList> mcl = getCodecList(env); if (mcl == NULL) { // Runtime exception already pending. @@ -70,7 +70,7 @@ static jstring android_media_MediaCodecList_getCodecName( } static jint android_media_MediaCodecList_findCodecByName( - JNIEnv *env, jobject thiz, jstring name) { + JNIEnv *env, jobject /* thiz */, jstring name) { if (name == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return -ENOENT; @@ -95,7 +95,7 @@ static jint android_media_MediaCodecList_findCodecByName( } static jboolean android_media_MediaCodecList_isEncoder( - JNIEnv *env, jobject thiz, jint index) { + JNIEnv *env, jobject /* thiz */, jint index) { sp<IMediaCodecList> mcl = getCodecList(env); if (mcl == NULL) { // Runtime exception already pending. @@ -112,7 +112,7 @@ static jboolean android_media_MediaCodecList_isEncoder( } static jarray android_media_MediaCodecList_getSupportedTypes( - JNIEnv *env, jobject thiz, jint index) { + JNIEnv *env, jobject /* thiz */, jint index) { sp<IMediaCodecList> mcl = getCodecList(env); if (mcl == NULL) { // Runtime exception already pending. @@ -144,7 +144,7 @@ static jarray android_media_MediaCodecList_getSupportedTypes( } static jobject android_media_MediaCodecList_getCodecCapabilities( - JNIEnv *env, jobject thiz, jint index, jstring type) { + JNIEnv *env, jobject /* thiz */, jint index, jstring type) { if (type == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return NULL; @@ -262,7 +262,7 @@ static jobject android_media_MediaCodecList_getCodecCapabilities( return caps; } -static void android_media_MediaCodecList_native_init(JNIEnv *env) { +static void android_media_MediaCodecList_native_init(JNIEnv* /* env */) { } static JNINativeMethod gMethods[] = { diff --git a/media/jni/android_media_MediaCrypto.cpp b/media/jni/android_media_MediaCrypto.cpp index a6f8dcd..d2216fb 100644 --- a/media/jni/android_media_MediaCrypto.cpp +++ b/media/jni/android_media_MediaCrypto.cpp @@ -224,7 +224,7 @@ static void android_media_MediaCrypto_native_finalize( } static jboolean android_media_MediaCrypto_isCryptoSchemeSupportedNative( - JNIEnv *env, jobject thiz, jbyteArray uuidObj) { + JNIEnv *env, jobject /* thiz */, jbyteArray uuidObj) { jsize uuidLength = env->GetArrayLength(uuidObj); if (uuidLength != 16) { diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp index 0fed27e..91eb499 100644 --- a/media/jni/android_media_MediaDrm.cpp +++ b/media/jni/android_media_MediaDrm.cpp @@ -667,7 +667,7 @@ static void android_media_MediaDrm_native_finalize( } static jboolean android_media_MediaDrm_isCryptoSchemeSupportedNative( - JNIEnv *env, jobject thiz, jbyteArray uuidObj, jstring jmimeType) { + JNIEnv *env, jobject /* thiz */, jbyteArray uuidObj, jstring jmimeType) { if (uuidObj == NULL) { jniThrowException(env, "java/lang/IllegalArgumentException", NULL); @@ -1137,7 +1137,7 @@ static void android_media_MediaDrm_setPropertyByteArray( } static void android_media_MediaDrm_setCipherAlgorithmNative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jstring jalgorithm) { sp<IDrm> drm = GetDrm(env, jdrm); @@ -1161,7 +1161,7 @@ static void android_media_MediaDrm_setCipherAlgorithmNative( } static void android_media_MediaDrm_setMacAlgorithmNative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jstring jalgorithm) { sp<IDrm> drm = GetDrm(env, jdrm); @@ -1186,7 +1186,7 @@ static void android_media_MediaDrm_setMacAlgorithmNative( static jbyteArray android_media_MediaDrm_encryptNative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jbyteArray jkeyId, jbyteArray jinput, jbyteArray jiv) { sp<IDrm> drm = GetDrm(env, jdrm); @@ -1217,7 +1217,7 @@ static jbyteArray android_media_MediaDrm_encryptNative( } static jbyteArray android_media_MediaDrm_decryptNative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jbyteArray jkeyId, jbyteArray jinput, jbyteArray jiv) { sp<IDrm> drm = GetDrm(env, jdrm); @@ -1247,7 +1247,7 @@ static jbyteArray android_media_MediaDrm_decryptNative( } static jbyteArray android_media_MediaDrm_signNative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jbyteArray jkeyId, jbyteArray jmessage) { sp<IDrm> drm = GetDrm(env, jdrm); @@ -1277,7 +1277,7 @@ static jbyteArray android_media_MediaDrm_signNative( } static jboolean android_media_MediaDrm_verifyNative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jbyteArray jkeyId, jbyteArray jmessage, jbyteArray jsignature) { sp<IDrm> drm = GetDrm(env, jdrm); @@ -1306,7 +1306,7 @@ static jboolean android_media_MediaDrm_verifyNative( static jbyteArray android_media_MediaDrm_signRSANative( - JNIEnv *env, jobject thiz, jobject jdrm, jbyteArray jsessionId, + JNIEnv *env, jobject /* thiz */, jobject jdrm, jbyteArray jsessionId, jstring jalgorithm, jbyteArray jwrappedKey, jbyteArray jmessage) { sp<IDrm> drm = GetDrm(env, jdrm); diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp index fbe5340..dae6d3b 100644 --- a/media/jni/android_media_MediaMetadataRetriever.cpp +++ b/media/jni/android_media_MediaMetadataRetriever.cpp @@ -77,7 +77,6 @@ static MediaMetadataRetriever* getRetriever(JNIEnv* env, jobject thiz) static void setRetriever(JNIEnv* env, jobject thiz, MediaMetadataRetriever* retriever) { // No lock is needed, since it is called internally by other methods that are protected - MediaMetadataRetriever *old = (MediaMetadataRetriever*) env->GetLongField(thiz, fields.context); env->SetLongField(thiz, fields.context, (jlong) retriever); } diff --git a/media/jni/android_media_MediaMuxer.cpp b/media/jni/android_media_MediaMuxer.cpp index 3fef446f..f234a1b 100644 --- a/media/jni/android_media_MediaMuxer.cpp +++ b/media/jni/android_media_MediaMuxer.cpp @@ -41,7 +41,7 @@ static fields_t gFields; using namespace android; static jint android_media_MediaMuxer_addTrack( - JNIEnv *env, jclass clazz, jlong nativeObject, jobjectArray keys, + JNIEnv *env, jclass /* clazz */, jlong nativeObject, jobjectArray keys, jobjectArray values) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { @@ -71,7 +71,7 @@ static jint android_media_MediaMuxer_addTrack( } static void android_media_MediaMuxer_writeSampleData( - JNIEnv *env, jclass clazz, jlong nativeObject, jint trackIndex, + JNIEnv *env, jclass /* clazz */, jlong nativeObject, jint trackIndex, jobject byteBuf, jint offset, jint size, jlong timeUs, jint flags) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { @@ -146,7 +146,7 @@ static jlong android_media_MediaMuxer_native_setup( } static void android_media_MediaMuxer_setOrientationHint( - JNIEnv *env, jclass clazz, jlong nativeObject, jint degrees) { + JNIEnv *env, jclass /* clazz */, jlong nativeObject, jint degrees) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { jniThrowException(env, "java/lang/IllegalStateException", @@ -164,7 +164,7 @@ static void android_media_MediaMuxer_setOrientationHint( } static void android_media_MediaMuxer_setLocation( - JNIEnv *env, jclass clazz, jlong nativeObject, jint latitude, jint longitude) { + JNIEnv *env, jclass /* clazz */, jlong nativeObject, jint latitude, jint longitude) { MediaMuxer* muxer = reinterpret_cast<MediaMuxer *>(nativeObject); status_t res = muxer->setLocation(latitude, longitude); @@ -175,7 +175,7 @@ static void android_media_MediaMuxer_setLocation( } } -static void android_media_MediaMuxer_start(JNIEnv *env, jclass clazz, +static void android_media_MediaMuxer_start(JNIEnv *env, jclass /* clazz */, jlong nativeObject) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { @@ -193,7 +193,7 @@ static void android_media_MediaMuxer_start(JNIEnv *env, jclass clazz, } -static void android_media_MediaMuxer_stop(JNIEnv *env, jclass clazz, +static void android_media_MediaMuxer_stop(JNIEnv *env, jclass /* clazz */, jlong nativeObject) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer == NULL) { @@ -212,7 +212,7 @@ static void android_media_MediaMuxer_stop(JNIEnv *env, jclass clazz, } static void android_media_MediaMuxer_native_release( - JNIEnv *env, jclass clazz, jlong nativeObject) { + JNIEnv* /* env */, jclass clazz, jlong nativeObject) { sp<MediaMuxer> muxer(reinterpret_cast<MediaMuxer *>(nativeObject)); if (muxer != NULL) { muxer->decStrong(clazz); diff --git a/media/jni/android_media_MediaProfiles.cpp b/media/jni/android_media_MediaProfiles.cpp index 007fc14..ca9db91 100644 --- a/media/jni/android_media_MediaProfiles.cpp +++ b/media/jni/android_media_MediaProfiles.cpp @@ -34,7 +34,7 @@ MediaProfiles *sProfiles = NULL; // This function is called from a static block in MediaProfiles.java class, // which won't run until the first time an instance of this class is used. static void -android_media_MediaProfiles_native_init(JNIEnv *env) +android_media_MediaProfiles_native_init(JNIEnv* /* env */) { ALOGV("native_init"); Mutex::Autolock lock(sLock); @@ -45,14 +45,14 @@ android_media_MediaProfiles_native_init(JNIEnv *env) } static jint -android_media_MediaProfiles_native_get_num_file_formats(JNIEnv *env, jobject thiz) +android_media_MediaProfiles_native_get_num_file_formats(JNIEnv* /* env */, jobject /* thiz */) { ALOGV("native_get_num_file_formats"); return (jint) sProfiles->getOutputFileFormats().size(); } static jint -android_media_MediaProfiles_native_get_file_format(JNIEnv *env, jobject thiz, jint index) +android_media_MediaProfiles_native_get_file_format(JNIEnv *env, jobject /* thiz */, jint index) { ALOGV("native_get_file_format: %d", index); Vector<output_format> formats = sProfiles->getOutputFileFormats(); @@ -65,14 +65,15 @@ android_media_MediaProfiles_native_get_file_format(JNIEnv *env, jobject thiz, ji } static jint -android_media_MediaProfiles_native_get_num_video_encoders(JNIEnv *env, jobject thiz) +android_media_MediaProfiles_native_get_num_video_encoders(JNIEnv* /* env */, jobject /* thiz */) { ALOGV("native_get_num_video_encoders"); return sProfiles->getVideoEncoders().size(); } static jobject -android_media_MediaProfiles_native_get_video_encoder_cap(JNIEnv *env, jobject thiz, jint index) +android_media_MediaProfiles_native_get_video_encoder_cap(JNIEnv *env, jobject /* thiz */, + jint index) { ALOGV("native_get_video_encoder_cap: %d", index); Vector<video_encoder> encoders = sProfiles->getVideoEncoders(); @@ -116,14 +117,15 @@ android_media_MediaProfiles_native_get_video_encoder_cap(JNIEnv *env, jobject th } static jint -android_media_MediaProfiles_native_get_num_audio_encoders(JNIEnv *env, jobject thiz) +android_media_MediaProfiles_native_get_num_audio_encoders(JNIEnv* /* env */, jobject /* thiz */) { ALOGV("native_get_num_audio_encoders"); return (jint) sProfiles->getAudioEncoders().size(); } static jobject -android_media_MediaProfiles_native_get_audio_encoder_cap(JNIEnv *env, jobject thiz, jint index) +android_media_MediaProfiles_native_get_audio_encoder_cap(JNIEnv *env, jobject /* thiz */, + jint index) { ALOGV("native_get_audio_encoder_cap: %d", index); Vector<audio_encoder> encoders = sProfiles->getAudioEncoders(); @@ -172,7 +174,8 @@ static bool isCamcorderQualityKnown(int quality) } static jobject -android_media_MediaProfiles_native_get_camcorder_profile(JNIEnv *env, jobject thiz, jint id, jint quality) +android_media_MediaProfiles_native_get_camcorder_profile(JNIEnv *env, jobject /* thiz */, jint id, + jint quality) { ALOGV("native_get_camcorder_profile: %d %d", id, quality); if (!isCamcorderQualityKnown(quality)) { @@ -221,7 +224,8 @@ android_media_MediaProfiles_native_get_camcorder_profile(JNIEnv *env, jobject th } static jboolean -android_media_MediaProfiles_native_has_camcorder_profile(JNIEnv *env, jobject thiz, jint id, jint quality) +android_media_MediaProfiles_native_has_camcorder_profile(JNIEnv* /* env */, jobject /* thiz */, + jint id, jint quality) { ALOGV("native_has_camcorder_profile: %d %d", id, quality); if (!isCamcorderQualityKnown(quality)) { @@ -233,14 +237,15 @@ android_media_MediaProfiles_native_has_camcorder_profile(JNIEnv *env, jobject th } static jint -android_media_MediaProfiles_native_get_num_video_decoders(JNIEnv *env, jobject thiz) +android_media_MediaProfiles_native_get_num_video_decoders(JNIEnv* /* env */, jobject /* thiz */) { ALOGV("native_get_num_video_decoders"); return (jint) sProfiles->getVideoDecoders().size(); } static jint -android_media_MediaProfiles_native_get_video_decoder_type(JNIEnv *env, jobject thiz, jint index) +android_media_MediaProfiles_native_get_video_decoder_type(JNIEnv *env, jobject /* thiz */, + jint index) { ALOGV("native_get_video_decoder_type: %d", index); Vector<video_decoder> decoders = sProfiles->getVideoDecoders(); @@ -254,14 +259,15 @@ android_media_MediaProfiles_native_get_video_decoder_type(JNIEnv *env, jobject t } static jint -android_media_MediaProfiles_native_get_num_audio_decoders(JNIEnv *env, jobject thiz) +android_media_MediaProfiles_native_get_num_audio_decoders(JNIEnv* /* env */, jobject /* thiz */) { ALOGV("native_get_num_audio_decoders"); return (jint) sProfiles->getAudioDecoders().size(); } static jint -android_media_MediaProfiles_native_get_audio_decoder_type(JNIEnv *env, jobject thiz, jint index) +android_media_MediaProfiles_native_get_audio_decoder_type(JNIEnv *env, jobject /* thiz */, + jint index) { ALOGV("native_get_audio_decoder_type: %d", index); Vector<audio_decoder> decoders = sProfiles->getAudioDecoders(); @@ -275,14 +281,17 @@ android_media_MediaProfiles_native_get_audio_decoder_type(JNIEnv *env, jobject t } static jint -android_media_MediaProfiles_native_get_num_image_encoding_quality_levels(JNIEnv *env, jobject thiz, jint cameraId) +android_media_MediaProfiles_native_get_num_image_encoding_quality_levels(JNIEnv* /* env */, + jobject /* thiz */, + jint cameraId) { ALOGV("native_get_num_image_encoding_quality_levels"); return (jint) sProfiles->getImageEncodingQualityLevels(cameraId).size(); } static jint -android_media_MediaProfiles_native_get_image_encoding_quality_level(JNIEnv *env, jobject thiz, jint cameraId, jint index) +android_media_MediaProfiles_native_get_image_encoding_quality_level(JNIEnv *env, jobject /* thiz */, + jint cameraId, jint index) { ALOGV("native_get_image_encoding_quality_level"); Vector<int> levels = sProfiles->getImageEncodingQualityLevels(cameraId); diff --git a/media/jni/android_media_MediaScanner.cpp b/media/jni/android_media_MediaScanner.cpp index 321c2e3..1a9384e 100644 --- a/media/jni/android_media_MediaScanner.cpp +++ b/media/jni/android_media_MediaScanner.cpp @@ -360,7 +360,6 @@ android_media_MediaScanner_extractAlbumArt( env->SetByteArrayRegion(array, 0, mediaAlbumArt->size(), data); } -done: free(mediaAlbumArt); // if NewByteArray() returned NULL, an out-of-memory // exception will have been raised. I just want to diff --git a/media/jni/android_media_ResampleInputStream.cpp b/media/jni/android_media_ResampleInputStream.cpp index d5a4a17..1549a30 100644 --- a/media/jni/android_media_ResampleInputStream.cpp +++ b/media/jni/android_media_ResampleInputStream.cpp @@ -73,7 +73,7 @@ static const int nFir21 = sizeof(fir21) / sizeof(fir21[0]); static const int BUF_SIZE = 2048; -static void android_media_ResampleInputStream_fir21(JNIEnv *env, jclass clazz, +static void android_media_ResampleInputStream_fir21(JNIEnv *env, jclass /* clazz */, jbyteArray jIn, jint jInOffset, jbyteArray jOut, jint jOutOffset, jint jNpoints) { diff --git a/media/jni/android_media_Utils.cpp b/media/jni/android_media_Utils.cpp index 54c5e9b..ea33a2f 100644 --- a/media/jni/android_media_Utils.cpp +++ b/media/jni/android_media_Utils.cpp @@ -136,8 +136,7 @@ static void SetMapInt32( jstring keyObj = env->NewStringUTF(key); jobject valueObj = makeIntegerObject(env, value); - jobject res = env->CallObjectMethod( - hashMapObj, hashMapPutID, keyObj, valueObj); + env->CallObjectMethod(hashMapObj, hashMapPutID, keyObj, valueObj); env->DeleteLocalRef(valueObj); valueObj = NULL; env->DeleteLocalRef(keyObj); keyObj = NULL; @@ -266,8 +265,7 @@ status_t ConvertMessageToMap( if (valueObj != NULL) { jstring keyObj = env->NewStringUTF(key); - jobject res = env->CallObjectMethod( - hashMap, hashMapPutID, keyObj, valueObj); + env->CallObjectMethod(hashMap, hashMapPutID, keyObj, valueObj); env->DeleteLocalRef(keyObj); keyObj = NULL; env->DeleteLocalRef(valueObj); valueObj = NULL; diff --git a/media/jni/android_mtp_MtpDatabase.cpp b/media/jni/android_mtp_MtpDatabase.cpp index 19b54a6..1a0675e 100644 --- a/media/jni/android_mtp_MtpDatabase.cpp +++ b/media/jni/android_mtp_MtpDatabase.cpp @@ -761,7 +761,7 @@ MtpResponseCode MyMtpDatabase::getObjectPropertyList(MtpObjectHandle handle, return result; } -static void foreachentry(ExifEntry *entry, void *user) { +static void foreachentry(ExifEntry *entry, void* /* user */) { char buf[1024]; ALOGI("entry %x, format %d, size %d: %s", entry->tag, entry->format, entry->size, exif_entry_get_value(entry, buf, sizeof(buf))); @@ -779,7 +779,6 @@ static long getLongFromExifEntry(ExifEntry *e) { MtpResponseCode MyMtpDatabase::getObjectInfo(MtpObjectHandle handle, MtpObjectInfo& info) { - char date[20]; MtpString path; int64_t length; MtpObjectFormat format; @@ -807,9 +806,11 @@ MtpResponseCode MyMtpDatabase::getObjectInfo(MtpObjectHandle handle, info.mDateModified = longValues[1]; env->ReleaseLongArrayElements(mLongBuffer, longValues, 0); -// info.mAssociationType = (format == MTP_FORMAT_ASSOCIATION ? -// MTP_ASSOCIATION_TYPE_GENERIC_FOLDER : -// MTP_ASSOCIATION_TYPE_UNDEFINED); + if ((false)) { + info.mAssociationType = (format == MTP_FORMAT_ASSOCIATION ? + MTP_ASSOCIATION_TYPE_GENERIC_FOLDER : + MTP_ASSOCIATION_TYPE_UNDEFINED); + } info.mAssociationType = MTP_ASSOCIATION_TYPE_UNDEFINED; jchar* str = env->GetCharArrayElements(mStringBuffer, 0); @@ -822,7 +823,9 @@ MtpResponseCode MyMtpDatabase::getObjectInfo(MtpObjectHandle handle, ExifData *exifdata = exif_data_new_from_file(path); if (exifdata) { - //exif_data_foreach_content(exifdata, foreachcontent, NULL); + if ((false)) { + exif_data_foreach_content(exifdata, foreachcontent, NULL); + } // XXX get this from exif, or parse jpeg header instead? ExifEntry *w = exif_content_get_entry( diff --git a/media/jni/android_mtp_MtpDevice.cpp b/media/jni/android_mtp_MtpDevice.cpp index 8e013a0..fb15770 100644 --- a/media/jni/android_mtp_MtpDevice.cpp +++ b/media/jni/android_mtp_MtpDevice.cpp @@ -91,14 +91,6 @@ MtpDevice* get_device_from_object(JNIEnv* env, jobject javaDevice) return (MtpDevice*)env->GetLongField(javaDevice, field_context); } -static void checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName) { - if (env->ExceptionCheck()) { - ALOGE("An exception was thrown by callback '%s'.", methodName); - LOGE_EX(env); - env->ExceptionClear(); - } -} - // ---------------------------------------------------------------------------- static jboolean diff --git a/media/jni/audioeffect/Android.mk b/media/jni/audioeffect/Android.mk index 3b1fb19..5c22c9b 100644 --- a/media/jni/audioeffect/Android.mk +++ b/media/jni/audioeffect/Android.mk @@ -2,20 +2,22 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ - android_media_AudioEffect.cpp \ - android_media_Visualizer.cpp + android_media_AudioEffect.cpp \ + android_media_Visualizer.cpp LOCAL_SHARED_LIBRARIES := \ - liblog \ - libcutils \ - libutils \ - libandroid_runtime \ - libnativehelper \ - libmedia + liblog \ + libcutils \ + libutils \ + libandroid_runtime \ + libnativehelper \ + libmedia LOCAL_C_INCLUDES := \ - $(call include-path-for, audio-effects) + $(call include-path-for, audio-effects) LOCAL_MODULE:= libaudioeffect_jni +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_SHARED_LIBRARY) diff --git a/media/jni/audioeffect/android_media_Visualizer.cpp b/media/jni/audioeffect/android_media_Visualizer.cpp index 8463d94..9183ad2 100644 --- a/media/jni/audioeffect/android_media_Visualizer.cpp +++ b/media/jni/audioeffect/android_media_Visualizer.cpp @@ -162,10 +162,6 @@ static void captureCallback(void* user, uint8_t *fft, uint32_t samplingrate) { - int arg1 = 0; - int arg2 = 0; - size_t size; - visualizer_callback_cookie *callbackInfo = (visualizer_callback_cookie *)user; JNIEnv *env = AndroidRuntime::getJNIEnv(); @@ -486,7 +482,7 @@ android_media_visualizer_native_getEnabled(JNIEnv *env, jobject thiz) } static jintArray -android_media_visualizer_native_getCaptureSizeRange(JNIEnv *env, jobject thiz) +android_media_visualizer_native_getCaptureSizeRange(JNIEnv *env, jobject /* thiz */) { jintArray jRange = env->NewIntArray(2); jint *nRange = env->GetIntArrayElements(jRange, NULL); @@ -498,7 +494,7 @@ android_media_visualizer_native_getCaptureSizeRange(JNIEnv *env, jobject thiz) } static jint -android_media_visualizer_native_getMaxCaptureRate(JNIEnv *env, jobject thiz) +android_media_visualizer_native_getMaxCaptureRate(JNIEnv* /* env */, jobject /* thiz */) { return (jint) Visualizer::getMaxCaptureRate(); } diff --git a/media/jni/soundpool/Android.mk b/media/jni/soundpool/Android.mk index ed8d7c1..3382512 100644 --- a/media/jni/soundpool/Android.mk +++ b/media/jni/soundpool/Android.mk @@ -2,16 +2,18 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ - android_media_SoundPool_SoundPoolImpl.cpp + android_media_SoundPool_SoundPoolImpl.cpp LOCAL_SHARED_LIBRARIES := \ - liblog \ - libcutils \ - libutils \ - libandroid_runtime \ - libnativehelper \ - libmedia + liblog \ + libcutils \ + libutils \ + libandroid_runtime \ + libnativehelper \ + libmedia LOCAL_MODULE:= libsoundpool +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_SHARED_LIBRARY) diff --git a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp index 89b2893..ce20e52 100644 --- a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp +++ b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp @@ -312,7 +312,7 @@ static JNINativeMethod gMethods[] = { static const char* const kClassPathName = "android/media/SoundPool$SoundPoolImpl"; -jint JNI_OnLoad(JavaVM* vm, void* reserved) +jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) { JNIEnv* env = NULL; jint result = -1; diff --git a/media/mca/filterfw/jni/Android.mk b/media/mca/filterfw/jni/Android.mk index 5aa5af1..67337e0 100644 --- a/media/mca/filterfw/jni/Android.mk +++ b/media/mca/filterfw/jni/Android.mk @@ -38,8 +38,8 @@ include $(LOCAL_PATH)/../native/libfilterfw.mk # Also need the JNI headers. LOCAL_C_INCLUDES += \ - $(JNI_H_INCLUDE) \ - $(LOCAL_PATH)/.. + $(JNI_H_INCLUDE) \ + $(LOCAL_PATH)/.. # Don't prelink this library. For more efficient code, you may want # to add this library to the prelink map and set this to true. However, @@ -47,5 +47,7 @@ LOCAL_C_INCLUDES += \ # part of a system image. LOCAL_PRELINK_MODULE := false +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_STATIC_LIBRARY) diff --git a/media/mca/filterfw/jni/jni_gl_environment.cpp b/media/mca/filterfw/jni/jni_gl_environment.cpp index 6da7b7c..5f00739 100644 --- a/media/mca/filterfw/jni/jni_gl_environment.cpp +++ b/media/mca/filterfw/jni/jni_gl_environment.cpp @@ -20,8 +20,8 @@ #include "jni/jni_gl_environment.h" #include "jni/jni_util.h" -#include <media/mediarecorder.h> #include "native/core/gl_env.h" +#include <media/mediarecorder.h> #include <gui/IGraphicBufferProducer.h> #include <gui/Surface.h> @@ -92,8 +92,8 @@ jboolean Java_android_filterfw_core_GLEnvironment_nativeIsContextActive(JNIEnv* return gl_env ? ToJBool(gl_env->IsContextActive()) : JNI_FALSE; } -jboolean Java_android_filterfw_core_GLEnvironment_nativeIsAnyContextActive(JNIEnv* env, - jclass clazz) { +jboolean Java_android_filterfw_core_GLEnvironment_nativeIsAnyContextActive(JNIEnv* /* env */, + jclass /* clazz */) { return ToJBool(GLEnv::IsAnyContextActive()); } diff --git a/media/mca/filterfw/jni/jni_init.cpp b/media/mca/filterfw/jni/jni_init.cpp index 3b131f1..956a5a5 100644 --- a/media/mca/filterfw/jni/jni_init.cpp +++ b/media/mca/filterfw/jni/jni_init.cpp @@ -27,7 +27,7 @@ using namespace android::filterfw; JavaVM* g_current_java_vm_ = NULL; -jint JNI_OnLoad(JavaVM* vm, void* reserved) { +jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) { // Set the current vm pointer g_current_java_vm_ = vm; diff --git a/media/mca/filterfw/native/Android.mk b/media/mca/filterfw/native/Android.mk index 46ee283..7c4703f 100644 --- a/media/mca/filterfw/native/Android.mk +++ b/media/mca/filterfw/native/Android.mk @@ -39,6 +39,8 @@ include $(LOCAL_PATH)/libfilterfw.mk # gcc should always be placed at the end. LOCAL_EXPORT_LDLIBS := -llog -lgcc +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + # TODO: Build a shared library as well? include $(BUILD_STATIC_LIBRARY) diff --git a/media/mca/filterfw/native/core/shader_program.cpp b/media/mca/filterfw/native/core/shader_program.cpp index d92eb31..002327b 100644 --- a/media/mca/filterfw/native/core/shader_program.cpp +++ b/media/mca/filterfw/native/core/shader_program.cpp @@ -318,15 +318,15 @@ GLuint ShaderProgram::CompileShader(GLenum shader_type, const char* source) { ALOGE("Problem compiling shader! Source:"); ALOGE("%s", source); std::string src(source); - unsigned int cur_pos = 0; - unsigned int next_pos = 0; - int line_number = 1; + size_t cur_pos = 0; + size_t next_pos = 0; + size_t line_number = 1; while ( (next_pos = src.find_first_of('\n', cur_pos)) != std::string::npos) { ALOGE("%03d : %s", line_number, src.substr(cur_pos, next_pos-cur_pos).c_str()); cur_pos = next_pos + 1; line_number++; } - ALOGE("%03d : %s", line_number, src.substr(cur_pos, next_pos-cur_pos).c_str()); + ALOGE("%03zu : %s", line_number, src.substr(cur_pos, next_pos-cur_pos).c_str()); GLint log_length = 0; glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length); diff --git a/media/mca/filterfw/native/core/vertex_frame.cpp b/media/mca/filterfw/native/core/vertex_frame.cpp index 822573f..9fb9eaa 100644 --- a/media/mca/filterfw/native/core/vertex_frame.cpp +++ b/media/mca/filterfw/native/core/vertex_frame.cpp @@ -25,10 +25,6 @@ namespace android { namespace filterfw { -// GL Extensions that are dynamically looked up at runtime -static PFNGLMAPBUFFEROESPROC GLMapBufferOES = NULL; -static PFNGLUNMAPBUFFEROESPROC GLUnmapBufferOES = NULL; - VertexFrame::VertexFrame(int size) : vbo_(0), size_(size) { diff --git a/media/mca/filterpacks/Android.mk b/media/mca/filterpacks/Android.mk index 6e54f60..d030749 100644 --- a/media/mca/filterpacks/Android.mk +++ b/media/mca/filterpacks/Android.mk @@ -28,6 +28,8 @@ LOCAL_SRC_FILES := native/base/geometry.cpp \ LOCAL_CFLAGS := -DANDROID +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include external/stlport/libstlport.mk include $(BUILD_STATIC_LIBRARY) @@ -50,4 +52,6 @@ LOCAL_SHARED_LIBRARIES := liblog libutils libfilterfw LOCAL_PRELINK_MODULE := false +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_SHARED_LIBRARY) diff --git a/media/mca/filterpacks/native/imageproc/invert.c b/media/mca/filterpacks/native/imageproc/invert.c index 5938aac..f5f9e27 100644 --- a/media/mca/filterpacks/native/imageproc/invert.c +++ b/media/mca/filterpacks/native/imageproc/invert.c @@ -16,12 +16,14 @@ #include <android/log.h> +#define ATTRIBUTE_UNUSED __attribute__((unused)) + int invert_process(const char** inputs, const int* input_sizes, int input_count, char* output, int output_size, - void* user_data) { + void* user_data ATTRIBUTE_UNUSED) { // Make sure we have exactly one input if (input_count != 1) return 0; diff --git a/media/mca/filterpacks/native/imageproc/to_rgba.c b/media/mca/filterpacks/native/imageproc/to_rgba.c index bf4db2a..80094c0 100644 --- a/media/mca/filterpacks/native/imageproc/to_rgba.c +++ b/media/mca/filterpacks/native/imageproc/to_rgba.c @@ -16,12 +16,14 @@ #include <stdlib.h> +#define ATTRIBUTE_UNUSED __attribute__((unused)) + int gray_to_rgb_process(const char** inputs, const int* input_sizes, int input_count, char* output, int output_size, - void* user_data) { + void* user_data ATTRIBUTE_UNUSED) { // Make sure we have exactly one input if (input_count != 1) return 0; @@ -52,7 +54,7 @@ int rgba_to_rgb_process(const char** inputs, int input_count, char* output, int output_size, - void* user_data) { + void* user_data ATTRIBUTE_UNUSED) { // Make sure we have exactly one input if (input_count != 1) return 0; @@ -84,7 +86,7 @@ int gray_to_rgba_process(const char** inputs, int input_count, char* output, int output_size, - void* user_data) { + void* user_data ATTRIBUTE_UNUSED) { // Make sure we have exactly one input if (input_count != 1) return 0; @@ -116,7 +118,7 @@ int rgb_to_rgba_process(const char** inputs, int input_count, char* output, int output_size, - void* user_data) { + void* user_data ATTRIBUTE_UNUSED) { // Make sure we have exactly one input if (input_count != 1) return 0; diff --git a/native/android/Android.mk b/native/android/Android.mk index cda38e0..b3a74a8 100644 --- a/native/android/Android.mk +++ b/native/android/Android.mk @@ -34,6 +34,8 @@ LOCAL_C_INCLUDES += \ frameworks/base/native/include \ frameworks/base/core/jni/android -LOCAL_MODULE:= libandroid +LOCAL_MODULE := libandroid + +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code include $(BUILD_SHARED_LIBRARY) diff --git a/native/graphics/jni/Android.mk b/native/graphics/jni/Android.mk index 3154030..88954f0 100644 --- a/native/graphics/jni/Android.mk +++ b/native/graphics/jni/Android.mk @@ -6,27 +6,29 @@ include $(CLEAR_VARS) # setup for skia optimizations # ifneq ($(ARCH_ARM_HAVE_VFP),true) - LOCAL_CFLAGS += -DSK_SOFTWARE_FLOAT + LOCAL_CFLAGS += -DSK_SOFTWARE_FLOAT endif ifeq ($(ARCH_ARM_HAVE_NEON),true) - LOCAL_CFLAGS += -D__ARM_HAVE_NEON + LOCAL_CFLAGS += -D__ARM_HAVE_NEON endif # our source files # LOCAL_SRC_FILES:= \ - bitmap.cpp + bitmap.cpp LOCAL_SHARED_LIBRARIES := \ libandroid_runtime \ libskia LOCAL_C_INCLUDES += \ - frameworks/base/native/include \ - frameworks/base/core/jni/android/graphics + frameworks/base/native/include \ + frameworks/base/core/jni/android/graphics LOCAL_MODULE:= libjnigraphics +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_SHARED_LIBRARY) diff --git a/native/graphics/jni/bitmap.cpp b/native/graphics/jni/bitmap.cpp index df0751d..ea32edc 100644 --- a/native/graphics/jni/bitmap.cpp +++ b/native/graphics/jni/bitmap.cpp @@ -15,7 +15,11 @@ */ #include <android/bitmap.h> + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" #include <GraphicsJNI.h> +#pragma GCC diagnostic pop int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap, AndroidBitmapInfo* info) { diff --git a/rs/jni/Android.mk b/rs/jni/Android.mk index f2c2e98..f1f0bfc 100644 --- a/rs/jni/Android.mk +++ b/rs/jni/Android.mk @@ -5,27 +5,28 @@ LOCAL_SRC_FILES:= \ android_renderscript_RenderScript.cpp LOCAL_SHARED_LIBRARIES := \ - libandroid_runtime \ - libandroidfw \ - libnativehelper \ - libRS \ - libcutils \ - liblog \ - libskia \ - libutils \ - libui \ - libgui + libandroid_runtime \ + libandroidfw \ + libnativehelper \ + libRS \ + libcutils \ + liblog \ + libskia \ + libutils \ + libui \ + libgui LOCAL_STATIC_LIBRARIES := rs_generated_include_dir := $(call intermediates-dir-for,SHARED_LIBRARIES,libRS,,) LOCAL_C_INCLUDES += \ - $(JNI_H_INCLUDE) \ - frameworks/rs \ - $(rs_generated_include_dir) + $(JNI_H_INCLUDE) \ + frameworks/rs \ + $(rs_generated_include_dir) LOCAL_CFLAGS += -Wno-unused-parameter -std=c++11 +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code LOCAL_ADDITIONAL_DEPENDENCIES := $(addprefix $(rs_generated_include_dir)/,rsgApiFuncDecl.h) LOCAL_MODULE:= librs_jni diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp index 2d94131..ff37150 100644 --- a/rs/jni/android_renderscript_RenderScript.cpp +++ b/rs/jni/android_renderscript_RenderScript.cpp @@ -43,10 +43,13 @@ #include <android_runtime/android_graphics_SurfaceTexture.h> //#define LOG_API ALOGE -#define LOG_API(...) +static constexpr bool kLogApi = false; using namespace android; +template <typename... T> +void UNUSED(T... t) {} + #define PER_ARRAY_TYPE(flag, fnc, readonly, ...) { \ jint len = 0; \ void *ptr = nullptr; \ @@ -106,6 +109,7 @@ using namespace android; default: \ break; \ } \ + UNUSED(len, ptr, typeBytes, relFlag); \ } @@ -168,7 +172,6 @@ private: static jfieldID gContextId = 0; static jfieldID gNativeBitmapID = 0; -static jfieldID gTypeNativeCache = 0; static void _nInit(JNIEnv *_env, jclass _this) { @@ -183,14 +186,18 @@ static void _nInit(JNIEnv *_env, jclass _this) static void nContextFinish(JNIEnv *_env, jobject _this, jlong con) { - LOG_API("nContextFinish, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nContextFinish, con(%p)", (RsContext)con); + } rsContextFinish((RsContext)con); } static void nAssignName(JNIEnv *_env, jobject _this, jlong con, jlong obj, jbyteArray str) { - LOG_API("nAssignName, con(%p), obj(%p)", (RsContext)con, (void *)obj); + if (kLogApi) { + ALOGD("nAssignName, con(%p), obj(%p)", (RsContext)con, (void *)obj); + } jint len = _env->GetArrayLength(str); jbyte * cptr = (jbyte *) _env->GetPrimitiveArrayCritical(str, 0); rsAssignName((RsContext)con, (void *)obj, (const char *)cptr, len); @@ -200,7 +207,9 @@ nAssignName(JNIEnv *_env, jobject _this, jlong con, jlong obj, jbyteArray str) static jstring nGetName(JNIEnv *_env, jobject _this, jlong con, jlong obj) { - LOG_API("nGetName, con(%p), obj(%p)", (RsContext)con, (void *)obj); + if (kLogApi) { + ALOGD("nGetName, con(%p), obj(%p)", (RsContext)con, (void *)obj); + } const char *name = nullptr; rsaGetName((RsContext)con, (void *)obj, &name); if(name == nullptr || strlen(name) == 0) { @@ -212,7 +221,9 @@ nGetName(JNIEnv *_env, jobject _this, jlong con, jlong obj) static void nObjDestroy(JNIEnv *_env, jobject _this, jlong con, jlong obj) { - LOG_API("nObjDestroy, con(%p) obj(%p)", (RsContext)con, (void *)obj); + if (kLogApi) { + ALOGD("nObjDestroy, con(%p) obj(%p)", (RsContext)con, (void *)obj); + } rsObjDestroy((RsContext)con, (void *)obj); } @@ -221,28 +232,36 @@ nObjDestroy(JNIEnv *_env, jobject _this, jlong con, jlong obj) static jlong nDeviceCreate(JNIEnv *_env, jobject _this) { - LOG_API("nDeviceCreate"); + if (kLogApi) { + ALOGD("nDeviceCreate"); + } return (jlong)(uintptr_t)rsDeviceCreate(); } static void nDeviceDestroy(JNIEnv *_env, jobject _this, jlong dev) { - LOG_API("nDeviceDestroy"); + if (kLogApi) { + ALOGD("nDeviceDestroy"); + } return rsDeviceDestroy((RsDevice)dev); } static void nDeviceSetConfig(JNIEnv *_env, jobject _this, jlong dev, jint p, jint value) { - LOG_API("nDeviceSetConfig dev(%p), param(%i), value(%i)", (void *)dev, p, value); + if (kLogApi) { + ALOGD("nDeviceSetConfig dev(%p), param(%i), value(%i)", (void *)dev, p, value); + } return rsDeviceSetConfig((RsDevice)dev, (RsDeviceParam)p, value); } static jlong nContextCreate(JNIEnv *_env, jobject _this, jlong dev, jint ver, jint sdkVer, jint ct) { - LOG_API("nContextCreate"); + if (kLogApi) { + ALOGD("nContextCreate"); + } return (jlong)(uintptr_t)rsContextCreate((RsDevice)dev, ver, sdkVer, (RsContextType)ct, 0); } @@ -266,14 +285,18 @@ nContextCreateGL(JNIEnv *_env, jobject _this, jlong dev, jint ver, jint sdkVer, sc.samplesPref = samplesPref; sc.samplesQ = samplesQ; - LOG_API("nContextCreateGL"); + if (kLogApi) { + ALOGD("nContextCreateGL"); + } return (jlong)(uintptr_t)rsContextCreateGL((RsDevice)dev, ver, sdkVer, sc, dpi); } static void nContextSetPriority(JNIEnv *_env, jobject _this, jlong con, jint p) { - LOG_API("ContextSetPriority, con(%p), priority(%i)", (RsContext)con, p); + if (kLogApi) { + ALOGD("ContextSetPriority, con(%p), priority(%i)", (RsContext)con, p); + } rsContextSetPriority((RsContext)con, p); } @@ -282,7 +305,10 @@ nContextSetPriority(JNIEnv *_env, jobject _this, jlong con, jint p) static void nContextSetSurface(JNIEnv *_env, jobject _this, jlong con, jint width, jint height, jobject wnd) { - LOG_API("nContextSetSurface, con(%p), width(%i), height(%i), surface(%p)", (RsContext)con, width, height, (Surface *)wnd); + if (kLogApi) { + ALOGD("nContextSetSurface, con(%p), width(%i), height(%i), surface(%p)", (RsContext)con, + width, height, (Surface *)wnd); + } ANativeWindow * window = nullptr; if (wnd == nullptr) { @@ -297,28 +323,36 @@ nContextSetSurface(JNIEnv *_env, jobject _this, jlong con, jint width, jint heig static void nContextDestroy(JNIEnv *_env, jobject _this, jlong con) { - LOG_API("nContextDestroy, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nContextDestroy, con(%p)", (RsContext)con); + } rsContextDestroy((RsContext)con); } static void nContextDump(JNIEnv *_env, jobject _this, jlong con, jint bits) { - LOG_API("nContextDump, con(%p) bits(%i)", (RsContext)con, bits); + if (kLogApi) { + ALOGD("nContextDump, con(%p) bits(%i)", (RsContext)con, bits); + } rsContextDump((RsContext)con, bits); } static void nContextPause(JNIEnv *_env, jobject _this, jlong con) { - LOG_API("nContextPause, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nContextPause, con(%p)", (RsContext)con); + } rsContextPause((RsContext)con); } static void nContextResume(JNIEnv *_env, jobject _this, jlong con) { - LOG_API("nContextResume, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nContextResume, con(%p)", (RsContext)con); + } rsContextResume((RsContext)con); } @@ -326,7 +360,9 @@ nContextResume(JNIEnv *_env, jobject _this, jlong con) static jstring nContextGetErrorMessage(JNIEnv *_env, jobject _this, jlong con) { - LOG_API("nContextGetErrorMessage, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nContextGetErrorMessage, con(%p)", (RsContext)con); + } char buf[1024]; size_t receiveLen; @@ -345,7 +381,9 @@ static jint nContextGetUserMessage(JNIEnv *_env, jobject _this, jlong con, jintArray data) { jint len = _env->GetArrayLength(data); - LOG_API("nContextGetMessage, con(%p), len(%i)", (RsContext)con, len); + if (kLogApi) { + ALOGD("nContextGetMessage, con(%p), len(%i)", (RsContext)con, len); + } jint *ptr = _env->GetIntArrayElements(data, nullptr); size_t receiveLen; uint32_t subID; @@ -363,7 +401,9 @@ nContextGetUserMessage(JNIEnv *_env, jobject _this, jlong con, jintArray data) static jint nContextPeekMessage(JNIEnv *_env, jobject _this, jlong con, jintArray auxData) { - LOG_API("nContextPeekMessage, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nContextPeekMessage, con(%p)", (RsContext)con); + } jint *auxDataPtr = _env->GetIntArrayElements(auxData, nullptr); size_t receiveLen; uint32_t subID; @@ -377,13 +417,17 @@ nContextPeekMessage(JNIEnv *_env, jobject _this, jlong con, jintArray auxData) static void nContextInitToClient(JNIEnv *_env, jobject _this, jlong con) { - LOG_API("nContextInitToClient, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nContextInitToClient, con(%p)", (RsContext)con); + } rsContextInitToClient((RsContext)con); } static void nContextDeinitToClient(JNIEnv *_env, jobject _this, jlong con) { - LOG_API("nContextDeinitToClient, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nContextDeinitToClient, con(%p)", (RsContext)con); + } rsContextDeinitToClient((RsContext)con); } @@ -396,7 +440,9 @@ nContextSendMessage(JNIEnv *_env, jobject _this, jlong con, jint id, jintArray d len = _env->GetArrayLength(data); ptr = _env->GetIntArrayElements(data, nullptr); } - LOG_API("nContextSendMessage, con(%p), id(%i), len(%i)", (RsContext)con, id, len); + if (kLogApi) { + ALOGD("nContextSendMessage, con(%p), id(%i), len(%i)", (RsContext)con, id, len); + } rsContextSendMessage((RsContext)con, id, (const uint8_t *)ptr, len * sizeof(int)); if (data) { _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); @@ -406,10 +452,15 @@ nContextSendMessage(JNIEnv *_env, jobject _this, jlong con, jint id, jintArray d static jlong -nElementCreate(JNIEnv *_env, jobject _this, jlong con, jlong type, jint kind, jboolean norm, jint size) +nElementCreate(JNIEnv *_env, jobject _this, jlong con, jlong type, jint kind, jboolean norm, + jint size) { - LOG_API("nElementCreate, con(%p), type(%i), kind(%i), norm(%i), size(%i)", (RsContext)con, type, kind, norm, size); - return (jlong)(uintptr_t)rsElementCreate((RsContext)con, (RsDataType)type, (RsDataKind)kind, norm, size); + if (kLogApi) { + ALOGD("nElementCreate, con(%p), type(%i), kind(%i), norm(%i), size(%i)", (RsContext)con, + type, kind, norm, size); + } + return (jlong)(uintptr_t)rsElementCreate((RsContext)con, (RsDataType)type, (RsDataKind)kind, + norm, size); } static jlong @@ -417,7 +468,9 @@ nElementCreate2(JNIEnv *_env, jobject _this, jlong con, jlongArray _ids, jobjectArray _names, jintArray _arraySizes) { int fieldCount = _env->GetArrayLength(_ids); - LOG_API("nElementCreate2, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nElementCreate2, con(%p)", (RsContext)con); + } jlong *jIds = _env->GetLongArrayElements(_ids, nullptr); jint *jArraySizes = _env->GetIntArrayElements(_arraySizes, nullptr); @@ -452,7 +505,9 @@ static void nElementGetNativeData(JNIEnv *_env, jobject _this, jlong con, jlong id, jintArray _elementData) { int dataSize = _env->GetArrayLength(_elementData); - LOG_API("nElementGetNativeData, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nElementGetNativeData, con(%p)", (RsContext)con); + } // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements assert(dataSize == 5); @@ -474,13 +529,16 @@ nElementGetSubElements(JNIEnv *_env, jobject _this, jlong con, jlong id, jintArray _arraySizes) { uint32_t dataSize = _env->GetArrayLength(_IDs); - LOG_API("nElementGetSubElements, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nElementGetSubElements, con(%p)", (RsContext)con); + } uintptr_t *ids = (uintptr_t*)malloc(dataSize * sizeof(uintptr_t)); const char **names = (const char **)malloc(dataSize * sizeof(const char *)); uint32_t *arraySizes = (uint32_t *)malloc(dataSize * sizeof(uint32_t)); - rsaElementGetSubElements((RsContext)con, (RsElement)id, ids, names, arraySizes, (uint32_t)dataSize); + rsaElementGetSubElements((RsContext)con, (RsElement)id, ids, names, arraySizes, + (uint32_t)dataSize); for(uint32_t i = 0; i < dataSize; i++) { const jlong id = (jlong)(uintptr_t)ids[i]; @@ -501,10 +559,13 @@ static jlong nTypeCreate(JNIEnv *_env, jobject _this, jlong con, jlong eid, jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces, jint yuv) { - LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i), yuv(%i)", - (RsContext)con, eid, dimx, dimy, dimz, mips, faces, yuv); + if (kLogApi) { + ALOGD("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i), yuv(%i)", + (RsContext)con, eid, dimx, dimy, dimz, mips, faces, yuv); + } - return (jlong)(uintptr_t)rsTypeCreate((RsContext)con, (RsElement)eid, dimx, dimy, dimz, mips, faces, yuv); + return (jlong)(uintptr_t)rsTypeCreate((RsContext)con, (RsElement)eid, dimx, dimy, dimz, mips, + faces, yuv); } static void @@ -515,7 +576,9 @@ nTypeGetNativeData(JNIEnv *_env, jobject _this, jlong con, jlong id, jlongArray int elementCount = _env->GetArrayLength(_typeData); assert(elementCount == 6); - LOG_API("nTypeGetNativeData, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nTypeGetNativeData, con(%p)", (RsContext)con); + } uintptr_t typeData[6]; rsaTypeGetNativeData((RsContext)con, (RsType)id, typeData, 6); @@ -529,25 +592,37 @@ nTypeGetNativeData(JNIEnv *_env, jobject _this, jlong con, jlong id, jlongArray // ----------------------------------- static jlong -nAllocationCreateTyped(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mips, jint usage, jlong pointer) +nAllocationCreateTyped(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mips, jint usage, + jlong pointer) { - LOG_API("nAllocationCreateTyped, con(%p), type(%p), mip(%i), usage(%i), ptr(%p)", (RsContext)con, (RsElement)type, mips, usage, (void *)pointer); - return (jlong)(uintptr_t) rsAllocationCreateTyped((RsContext)con, (RsType)type, (RsAllocationMipmapControl)mips, (uint32_t)usage, (uintptr_t)pointer); + if (kLogApi) { + ALOGD("nAllocationCreateTyped, con(%p), type(%p), mip(%i), usage(%i), ptr(%p)", + (RsContext)con, (RsElement)type, mips, usage, (void *)pointer); + } + return (jlong)(uintptr_t) rsAllocationCreateTyped((RsContext)con, (RsType)type, + (RsAllocationMipmapControl)mips, + (uint32_t)usage, (uintptr_t)pointer); } static void nAllocationSyncAll(JNIEnv *_env, jobject _this, jlong con, jlong a, jint bits) { - LOG_API("nAllocationSyncAll, con(%p), a(%p), bits(0x%08x)", (RsContext)con, (RsAllocation)a, bits); + if (kLogApi) { + ALOGD("nAllocationSyncAll, con(%p), a(%p), bits(0x%08x)", (RsContext)con, (RsAllocation)a, + bits); + } rsAllocationSyncAll((RsContext)con, (RsAllocation)a, (RsAllocationUsageType)bits); } static jobject nAllocationGetSurface(JNIEnv *_env, jobject _this, jlong con, jlong a) { - LOG_API("nAllocationGetSurface, con(%p), a(%p)", (RsContext)con, (RsAllocation)a); + if (kLogApi) { + ALOGD("nAllocationGetSurface, con(%p), a(%p)", (RsContext)con, (RsAllocation)a); + } - IGraphicBufferProducer *v = (IGraphicBufferProducer *)rsAllocationGetSurface((RsContext)con, (RsAllocation)a); + IGraphicBufferProducer *v = (IGraphicBufferProducer *)rsAllocationGetSurface((RsContext)con, + (RsAllocation)a); sp<IGraphicBufferProducer> bp = v; v->decStrong(nullptr); @@ -558,28 +633,35 @@ nAllocationGetSurface(JNIEnv *_env, jobject _this, jlong con, jlong a) static void nAllocationSetSurface(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jobject sur) { - LOG_API("nAllocationSetSurface, con(%p), alloc(%p), surface(%p)", - (RsContext)con, (RsAllocation)alloc, (Surface *)sur); + if (kLogApi) { + ALOGD("nAllocationSetSurface, con(%p), alloc(%p), surface(%p)", (RsContext)con, + (RsAllocation)alloc, (Surface *)sur); + } sp<Surface> s; if (sur != 0) { s = android_view_Surface_getSurface(_env, sur); } - rsAllocationSetSurface((RsContext)con, (RsAllocation)alloc, static_cast<ANativeWindow *>(s.get())); + rsAllocationSetSurface((RsContext)con, (RsAllocation)alloc, + static_cast<ANativeWindow *>(s.get())); } static void nAllocationIoSend(JNIEnv *_env, jobject _this, jlong con, jlong alloc) { - LOG_API("nAllocationIoSend, con(%p), alloc(%p)", (RsContext)con, alloc); + if (kLogApi) { + ALOGD("nAllocationIoSend, con(%p), alloc(%p)", (RsContext)con, alloc); + } rsAllocationIoSend((RsContext)con, (RsAllocation)alloc); } static void nAllocationIoReceive(JNIEnv *_env, jobject _this, jlong con, jlong alloc) { - LOG_API("nAllocationIoReceive, con(%p), alloc(%p)", (RsContext)con, alloc); + if (kLogApi) { + ALOGD("nAllocationIoReceive, con(%p), alloc(%p)", (RsContext)con, alloc); + } rsAllocationIoReceive((RsContext)con, (RsAllocation)alloc); } @@ -587,12 +669,15 @@ nAllocationIoReceive(JNIEnv *_env, jobject _this, jlong con, jlong alloc) static void nAllocationGenerateMipmaps(JNIEnv *_env, jobject _this, jlong con, jlong alloc) { - LOG_API("nAllocationGenerateMipmaps, con(%p), a(%p)", (RsContext)con, (RsAllocation)alloc); + if (kLogApi) { + ALOGD("nAllocationGenerateMipmaps, con(%p), a(%p)", (RsContext)con, (RsAllocation)alloc); + } rsAllocationGenerateMipmaps((RsContext)con, (RsAllocation)alloc); } static jlong -nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mip, jobject jbitmap, jint usage) +nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mip, + jobject jbitmap, jint usage) { SkBitmap const * nativeBitmap = (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID); @@ -608,7 +693,8 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong type, } static jlong -nAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mip, jobject jbitmap, jint usage) +nAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, jlong con, jlong type, + jint mip, jobject jbitmap, jint usage) { SkBitmap const * nativeBitmap = (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID); @@ -624,7 +710,8 @@ nAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, jlong con, } static jlong -nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mip, jobject jbitmap, jint usage) +nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mip, + jobject jbitmap, jint usage) { SkBitmap const * nativeBitmap = (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID); @@ -670,31 +757,33 @@ nAllocationCopyToBitmap(JNIEnv *_env, jobject _this, jlong con, jlong alloc, job bitmap.notifyPixelsChanged(); } -static void ReleaseBitmapCallback(void *bmp) -{ - SkBitmap const * nativeBitmap = (SkBitmap const *)bmp; - nativeBitmap->unlockPixels(); -} - - // Copies from the Java object data into the Allocation pointed to by _alloc. static void nAllocationData1D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint offset, jint lod, jint count, jobject data, jint sizeBytes, jint dataType) { RsAllocation *alloc = (RsAllocation *)_alloc; - LOG_API("nAllocation1DData, con(%p), adapter(%p), offset(%i), count(%i), sizeBytes(%i), dataType(%i)", - (RsContext)con, (RsAllocation)alloc, offset, count, sizeBytes, dataType); - PER_ARRAY_TYPE(nullptr, rsAllocation1DData, true, (RsContext)con, alloc, offset, lod, count, ptr, sizeBytes); + if (kLogApi) { + ALOGD("nAllocation1DData, con(%p), adapter(%p), offset(%i), count(%i), sizeBytes(%i), " + "dataType(%i)", (RsContext)con, (RsAllocation)alloc, offset, count, sizeBytes, + dataType); + } + PER_ARRAY_TYPE(nullptr, rsAllocation1DData, true, (RsContext)con, alloc, offset, lod, count, + ptr, sizeBytes); } // Copies from the Java array data into the Allocation pointed to by alloc. static void // native void rsnAllocationElementData1D(long con, long id, int xoff, int compIdx, byte[] d, int sizeBytes); -nAllocationElementData1D(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jint offset, jint lod, jint compIdx, jbyteArray data, jint sizeBytes) +nAllocationElementData1D(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jint offset, jint lod, + jint compIdx, jbyteArray data, jint sizeBytes) { jint len = _env->GetArrayLength(data); - LOG_API("nAllocationElementData1D, con(%p), alloc(%p), offset(%i), comp(%i), len(%i), sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, offset, compIdx, len, sizeBytes); + if (kLogApi) { + ALOGD("nAllocationElementData1D, con(%p), alloc(%p), offset(%i), comp(%i), len(%i), " + "sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, offset, compIdx, len, + sizeBytes); + } jbyte *ptr = _env->GetByteArrayElements(data, nullptr); rsAllocation1DElementData((RsContext)con, (RsAllocation)alloc, offset, lod, ptr, sizeBytes, compIdx); _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); @@ -707,8 +796,10 @@ nAllocationData2D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint xof { RsAllocation *alloc = (RsAllocation *)_alloc; RsAllocationCubemapFace face = (RsAllocationCubemapFace)_face; - LOG_API("nAllocation2DData, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i) type(%i)", - (RsContext)con, alloc, xoff, yoff, w, h, sizeBytes, dataType); + if (kLogApi) { + ALOGD("nAllocation2DData, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i) " + "type(%i)", (RsContext)con, alloc, xoff, yoff, w, h, sizeBytes, dataType); + } PER_ARRAY_TYPE(nullptr, rsAllocation2DData, true, (RsContext)con, alloc, xoff, yoff, lod, face, w, h, ptr, sizeBytes, 0); } @@ -722,11 +813,13 @@ nAllocationData2D_alloc(JNIEnv *_env, jobject _this, jlong con, jlong srcAlloc, jint srcXoff, jint srcYoff, jint srcMip, jint srcFace) { - LOG_API("nAllocation2DData_s, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i)," - " dstMip(%i), dstFace(%i), width(%i), height(%i)," - " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i), srcFace(%i)", - (RsContext)con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace, - width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace); + if (kLogApi) { + ALOGD("nAllocation2DData_s, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i)," + " dstMip(%i), dstFace(%i), width(%i), height(%i)," + " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i), srcFace(%i)", + (RsContext)con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace, + width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace); + } rsAllocationCopy2DRange((RsContext)con, (RsAllocation)dstAlloc, @@ -744,8 +837,11 @@ nAllocationData3D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint xof jint w, jint h, jint d, jobject data, int sizeBytes, int dataType) { RsAllocation *alloc = (RsAllocation *)_alloc; - LOG_API("nAllocation3DData, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), lod(%i), w(%i), h(%i), d(%i), sizeBytes(%i)", - (RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, sizeBytes); + if (kLogApi) { + ALOGD("nAllocation3DData, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), lod(%i), w(%i)," + " h(%i), d(%i), sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, + lod, w, h, d, sizeBytes); + } PER_ARRAY_TYPE(nullptr, rsAllocation3DData, true, (RsContext)con, alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0); } @@ -759,11 +855,13 @@ nAllocationData3D_alloc(JNIEnv *_env, jobject _this, jlong con, jlong srcAlloc, jint srcXoff, jint srcYoff, jint srcZoff, jint srcMip) { - LOG_API("nAllocationData3D_alloc, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i)," - " dstMip(%i), width(%i), height(%i)," - " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i)", - (RsContext)con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, - width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip); + if (kLogApi) { + ALOGD("nAllocationData3D_alloc, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i)," + " dstMip(%i), width(%i), height(%i)," + " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i)", + (RsContext)con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, + width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip); + } rsAllocationCopy3DRange((RsContext)con, (RsAllocation)dstAlloc, @@ -779,7 +877,9 @@ static void nAllocationRead(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jobject data, int dataType) { RsAllocation *alloc = (RsAllocation *)_alloc; - LOG_API("nAllocationRead, con(%p), alloc(%p)", (RsContext)con, (RsAllocation)alloc); + if (kLogApi) { + ALOGD("nAllocationRead, con(%p), alloc(%p)", (RsContext)con, (RsAllocation)alloc); + } PER_ARRAY_TYPE(0, rsAllocationRead, false, (RsContext)con, alloc, ptr, len * typeBytes); } @@ -789,8 +889,10 @@ nAllocationRead1D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint off jint count, jobject data, int sizeBytes, int dataType) { RsAllocation *alloc = (RsAllocation *)_alloc; - LOG_API("nAllocation1DRead, con(%p), adapter(%p), offset(%i), count(%i), sizeBytes(%i), dataType(%i)", - (RsContext)con, alloc, offset, count, sizeBytes, dataType); + if (kLogApi) { + ALOGD("nAllocation1DRead, con(%p), adapter(%p), offset(%i), count(%i), sizeBytes(%i), " + "dataType(%i)", (RsContext)con, alloc, offset, count, sizeBytes, dataType); + } PER_ARRAY_TYPE(0, rsAllocation1DRead, false, (RsContext)con, alloc, offset, lod, count, ptr, sizeBytes); } @@ -801,22 +903,30 @@ nAllocationRead2D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint xof { RsAllocation *alloc = (RsAllocation *)_alloc; RsAllocationCubemapFace face = (RsAllocationCubemapFace)_face; - LOG_API("nAllocation2DRead, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i) type(%i)", - (RsContext)con, alloc, xoff, yoff, w, h, sizeBytes, dataType); - PER_ARRAY_TYPE(0, rsAllocation2DRead, false, (RsContext)con, alloc, xoff, yoff, lod, face, w, h, ptr, sizeBytes, 0); + if (kLogApi) { + ALOGD("nAllocation2DRead, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i) " + "type(%i)", (RsContext)con, alloc, xoff, yoff, w, h, sizeBytes, dataType); + } + PER_ARRAY_TYPE(0, rsAllocation2DRead, false, (RsContext)con, alloc, xoff, yoff, lod, face, w, h, + ptr, sizeBytes, 0); } static jlong nAllocationGetType(JNIEnv *_env, jobject _this, jlong con, jlong a) { - LOG_API("nAllocationGetType, con(%p), a(%p)", (RsContext)con, (RsAllocation)a); + if (kLogApi) { + ALOGD("nAllocationGetType, con(%p), a(%p)", (RsContext)con, (RsAllocation)a); + } return (jlong)(uintptr_t) rsaAllocationGetType((RsContext)con, (RsAllocation)a); } static void nAllocationResize1D(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jint dimX) { - LOG_API("nAllocationResize1D, con(%p), alloc(%p), sizeX(%i)", (RsContext)con, (RsAllocation)alloc, dimX); + if (kLogApi) { + ALOGD("nAllocationResize1D, con(%p), alloc(%p), sizeX(%i)", (RsContext)con, + (RsAllocation)alloc, dimX); + } rsAllocationResize1D((RsContext)con, (RsAllocation)alloc, dimX); } @@ -947,21 +1057,29 @@ nFontCreateFromAsset(JNIEnv *_env, jobject _this, jlong con, jobject _assetMgr, static void nScriptBindAllocation(JNIEnv *_env, jobject _this, jlong con, jlong script, jlong alloc, jint slot) { - LOG_API("nScriptBindAllocation, con(%p), script(%p), alloc(%p), slot(%i)", (RsContext)con, (RsScript)script, (RsAllocation)alloc, slot); + if (kLogApi) { + ALOGD("nScriptBindAllocation, con(%p), script(%p), alloc(%p), slot(%i)", (RsContext)con, + (RsScript)script, (RsAllocation)alloc, slot); + } rsScriptBindAllocation((RsContext)con, (RsScript)script, (RsAllocation)alloc, slot); } static void nScriptSetVarI(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jint val) { - LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i)", (RsContext)con, (void *)script, slot, val); + if (kLogApi) { + ALOGD("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i)", (RsContext)con, (void *)script, + slot, val); + } rsScriptSetVarI((RsContext)con, (RsScript)script, slot, val); } static jint nScriptGetVarI(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot) { - LOG_API("nScriptGetVarI, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + if (kLogApi) { + ALOGD("nScriptGetVarI, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + } int value = 0; rsScriptGetVarV((RsContext)con, (RsScript)script, slot, &value, sizeof(value)); return value; @@ -970,21 +1088,29 @@ nScriptGetVarI(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot) static void nScriptSetVarObj(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jlong val) { - LOG_API("nScriptSetVarObj, con(%p), s(%p), slot(%i), val(%i)", (RsContext)con, (void *)script, slot, val); + if (kLogApi) { + ALOGD("nScriptSetVarObj, con(%p), s(%p), slot(%i), val(%i)", (RsContext)con, (void *)script, + slot, val); + } rsScriptSetVarObj((RsContext)con, (RsScript)script, slot, (RsObjectBase)val); } static void nScriptSetVarJ(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jlong val) { - LOG_API("nScriptSetVarJ, con(%p), s(%p), slot(%i), val(%lli)", (RsContext)con, (void *)script, slot, val); + if (kLogApi) { + ALOGD("nScriptSetVarJ, con(%p), s(%p), slot(%i), val(%lli)", (RsContext)con, (void *)script, + slot, val); + } rsScriptSetVarJ((RsContext)con, (RsScript)script, slot, val); } static jlong nScriptGetVarJ(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot) { - LOG_API("nScriptGetVarJ, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + if (kLogApi) { + ALOGD("nScriptGetVarJ, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + } jlong value = 0; rsScriptGetVarV((RsContext)con, (RsScript)script, slot, &value, sizeof(value)); return value; @@ -993,14 +1119,19 @@ nScriptGetVarJ(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot) static void nScriptSetVarF(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, float val) { - LOG_API("nScriptSetVarF, con(%p), s(%p), slot(%i), val(%f)", (RsContext)con, (void *)script, slot, val); + if (kLogApi) { + ALOGD("nScriptSetVarF, con(%p), s(%p), slot(%i), val(%f)", (RsContext)con, (void *)script, + slot, val); + } rsScriptSetVarF((RsContext)con, (RsScript)script, slot, val); } static jfloat nScriptGetVarF(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot) { - LOG_API("nScriptGetVarF, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + if (kLogApi) { + ALOGD("nScriptGetVarF, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + } jfloat value = 0; rsScriptGetVarV((RsContext)con, (RsScript)script, slot, &value, sizeof(value)); return value; @@ -1009,14 +1140,19 @@ nScriptGetVarF(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot) static void nScriptSetVarD(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, double val) { - LOG_API("nScriptSetVarD, con(%p), s(%p), slot(%i), val(%lf)", (RsContext)con, (void *)script, slot, val); + if (kLogApi) { + ALOGD("nScriptSetVarD, con(%p), s(%p), slot(%i), val(%lf)", (RsContext)con, (void *)script, + slot, val); + } rsScriptSetVarD((RsContext)con, (RsScript)script, slot, val); } static jdouble nScriptGetVarD(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot) { - LOG_API("nScriptGetVarD, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + if (kLogApi) { + ALOGD("nScriptGetVarD, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + } jdouble value = 0; rsScriptGetVarV((RsContext)con, (RsScript)script, slot, &value, sizeof(value)); return value; @@ -1025,7 +1161,9 @@ nScriptGetVarD(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot) static void nScriptSetVarV(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jbyteArray data) { - LOG_API("nScriptSetVarV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + if (kLogApi) { + ALOGD("nScriptSetVarV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + } jint len = _env->GetArrayLength(data); jbyte *ptr = _env->GetByteArrayElements(data, nullptr); rsScriptSetVarV((RsContext)con, (RsScript)script, slot, ptr, len); @@ -1035,7 +1173,9 @@ nScriptSetVarV(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, static void nScriptGetVarV(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jbyteArray data) { - LOG_API("nScriptSetVarV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + if (kLogApi) { + ALOGD("nScriptSetVarV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + } jint len = _env->GetArrayLength(data); jbyte *ptr = _env->GetByteArrayElements(data, nullptr); rsScriptGetVarV((RsContext)con, (RsScript)script, slot, ptr, len); @@ -1043,9 +1183,12 @@ nScriptGetVarV(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, } static void -nScriptSetVarVE(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jbyteArray data, jlong elem, jintArray dims) +nScriptSetVarVE(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jbyteArray data, + jlong elem, jintArray dims) { - LOG_API("nScriptSetVarVE, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + if (kLogApi) { + ALOGD("nScriptSetVarVE, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + } jint len = _env->GetArrayLength(data); jbyte *ptr = _env->GetByteArrayElements(data, nullptr); jint dimsLen = _env->GetArrayLength(dims) * sizeof(int); @@ -1060,7 +1203,9 @@ nScriptSetVarVE(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, static void nScriptSetTimeZone(JNIEnv *_env, jobject _this, jlong con, jlong script, jbyteArray timeZone) { - LOG_API("nScriptCSetTimeZone, con(%p), s(%p)", (RsContext)con, (void *)script); + if (kLogApi) { + ALOGD("nScriptCSetTimeZone, con(%p), s(%p)", (RsContext)con, (void *)script); + } jint length = _env->GetArrayLength(timeZone); jbyte* timeZone_ptr; @@ -1076,14 +1221,18 @@ nScriptSetTimeZone(JNIEnv *_env, jobject _this, jlong con, jlong script, jbyteAr static void nScriptInvoke(JNIEnv *_env, jobject _this, jlong con, jlong obj, jint slot) { - LOG_API("nScriptInvoke, con(%p), script(%p)", (RsContext)con, (void *)obj); + if (kLogApi) { + ALOGD("nScriptInvoke, con(%p), script(%p)", (RsContext)con, (void *)obj); + } rsScriptInvoke((RsContext)con, (RsScript)obj, slot); } static void nScriptInvokeV(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jbyteArray data) { - LOG_API("nScriptInvokeV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + if (kLogApi) { + ALOGD("nScriptInvokeV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + } jint len = _env->GetArrayLength(data); jbyte *ptr = _env->GetByteArrayElements(data, nullptr); rsScriptInvokeV((RsContext)con, (RsScript)script, slot, ptr, len); @@ -1095,8 +1244,9 @@ nScriptForEach(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jlongArray ains, jlong aout, jbyteArray params, jintArray limits) { - LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", (RsContext)con, - (void *)script, slot); + if (kLogApi) { + ALOGD("nScriptForEach, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); + } jint in_len = 0; jlong *in_ptr = nullptr; @@ -1140,6 +1290,7 @@ nScriptForEach(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, limit_ptr = _env->GetIntArrayElements(limits, nullptr); assert(limit_len == 6); + UNUSED(limit_len); // As the assert might not be compiled. sc.xStart = limit_ptr[0]; sc.xEnd = limit_ptr[1]; @@ -1176,7 +1327,9 @@ nScriptCCreate(JNIEnv *_env, jobject _this, jlong con, jstring resName, jstring cacheDir, jbyteArray scriptRef, jint length) { - LOG_API("nScriptCCreate, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nScriptCCreate, con(%p)", (RsContext)con); + } AutoJavaStringToUTF8 resNameUTF(_env, resName); AutoJavaStringToUTF8 cacheDirUTF(_env, cacheDir); @@ -1223,21 +1376,30 @@ exit: static jlong nScriptIntrinsicCreate(JNIEnv *_env, jobject _this, jlong con, jint id, jlong eid) { - LOG_API("nScriptIntrinsicCreate, con(%p) id(%i) element(%p)", (RsContext)con, id, (void *)eid); + if (kLogApi) { + ALOGD("nScriptIntrinsicCreate, con(%p) id(%i) element(%p)", (RsContext)con, id, + (void *)eid); + } return (jlong)(uintptr_t)rsScriptIntrinsicCreate((RsContext)con, id, (RsElement)eid); } static jlong nScriptKernelIDCreate(JNIEnv *_env, jobject _this, jlong con, jlong sid, jint slot, jint sig) { - LOG_API("nScriptKernelIDCreate, con(%p) script(%p), slot(%i), sig(%i)", (RsContext)con, (void *)sid, slot, sig); + if (kLogApi) { + ALOGD("nScriptKernelIDCreate, con(%p) script(%p), slot(%i), sig(%i)", (RsContext)con, + (void *)sid, slot, sig); + } return (jlong)(uintptr_t)rsScriptKernelIDCreate((RsContext)con, (RsScript)sid, slot, sig); } static jlong nScriptFieldIDCreate(JNIEnv *_env, jobject _this, jlong con, jlong sid, jint slot) { - LOG_API("nScriptFieldIDCreate, con(%p) script(%p), slot(%i)", (RsContext)con, (void *)sid, slot); + if (kLogApi) { + ALOGD("nScriptFieldIDCreate, con(%p) script(%p), slot(%i)", (RsContext)con, (void *)sid, + slot); + } return (jlong)(uintptr_t)rsScriptFieldIDCreate((RsContext)con, (RsScript)sid, slot); } @@ -1245,7 +1407,9 @@ static jlong nScriptGroupCreate(JNIEnv *_env, jobject _this, jlong con, jlongArray _kernels, jlongArray _src, jlongArray _dstk, jlongArray _dstf, jlongArray _types) { - LOG_API("nScriptGroupCreate, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nScriptGroupCreate, con(%p)", (RsContext)con); + } jint kernelsLen = _env->GetArrayLength(_kernels); jlong *jKernelsPtr = _env->GetLongArrayElements(_kernels, nullptr); @@ -1305,23 +1469,29 @@ nScriptGroupCreate(JNIEnv *_env, jobject _this, jlong con, jlongArray _kernels, static void nScriptGroupSetInput(JNIEnv *_env, jobject _this, jlong con, jlong gid, jlong kid, jlong alloc) { - LOG_API("nScriptGroupSetInput, con(%p) group(%p), kernelId(%p), alloc(%p)", (RsContext)con, - (void *)gid, (void *)kid, (void *)alloc); + if (kLogApi) { + ALOGD("nScriptGroupSetInput, con(%p) group(%p), kernelId(%p), alloc(%p)", (RsContext)con, + (void *)gid, (void *)kid, (void *)alloc); + } rsScriptGroupSetInput((RsContext)con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc); } static void nScriptGroupSetOutput(JNIEnv *_env, jobject _this, jlong con, jlong gid, jlong kid, jlong alloc) { - LOG_API("nScriptGroupSetOutput, con(%p) group(%p), kernelId(%p), alloc(%p)", (RsContext)con, - (void *)gid, (void *)kid, (void *)alloc); + if (kLogApi) { + ALOGD("nScriptGroupSetOutput, con(%p) group(%p), kernelId(%p), alloc(%p)", (RsContext)con, + (void *)gid, (void *)kid, (void *)alloc); + } rsScriptGroupSetOutput((RsContext)con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc); } static void nScriptGroupExecute(JNIEnv *_env, jobject _this, jlong con, jlong gid) { - LOG_API("nScriptGroupSetOutput, con(%p) group(%p)", (RsContext)con, (void *)gid); + if (kLogApi) { + ALOGD("nScriptGroupSetOutput, con(%p) group(%p)", (RsContext)con, (void *)gid); + } rsScriptGroupExecute((RsContext)con, (RsScriptGroup)gid); } @@ -1334,7 +1504,9 @@ nProgramStoreCreate(JNIEnv *_env, jobject _this, jlong con, jint srcFunc, jint destFunc, jint depthFunc) { - LOG_API("nProgramStoreCreate, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nProgramStoreCreate, con(%p)", (RsContext)con); + } return (jlong)(uintptr_t)rsProgramStoreCreate((RsContext)con, colorMaskR, colorMaskG, colorMaskB, colorMaskA, depthMask, ditherEnable, (RsBlendSrcFunc)srcFunc, (RsBlendDstFunc)destFunc, (RsDepthFunc)depthFunc); @@ -1345,21 +1517,30 @@ nProgramStoreCreate(JNIEnv *_env, jobject _this, jlong con, static void nProgramBindConstants(JNIEnv *_env, jobject _this, jlong con, jlong vpv, jint slot, jlong a) { - LOG_API("nProgramBindConstants, con(%p), vpf(%p), sloat(%i), a(%p)", (RsContext)con, (RsProgramVertex)vpv, slot, (RsAllocation)a); + if (kLogApi) { + ALOGD("nProgramBindConstants, con(%p), vpf(%p), sloat(%i), a(%p)", (RsContext)con, + (RsProgramVertex)vpv, slot, (RsAllocation)a); + } rsProgramBindConstants((RsContext)con, (RsProgram)vpv, slot, (RsAllocation)a); } static void nProgramBindTexture(JNIEnv *_env, jobject _this, jlong con, jlong vpf, jint slot, jlong a) { - LOG_API("nProgramBindTexture, con(%p), vpf(%p), slot(%i), a(%p)", (RsContext)con, (RsProgramFragment)vpf, slot, (RsAllocation)a); + if (kLogApi) { + ALOGD("nProgramBindTexture, con(%p), vpf(%p), slot(%i), a(%p)", (RsContext)con, + (RsProgramFragment)vpf, slot, (RsAllocation)a); + } rsProgramBindTexture((RsContext)con, (RsProgramFragment)vpf, slot, (RsAllocation)a); } static void nProgramBindSampler(JNIEnv *_env, jobject _this, jlong con, jlong vpf, jint slot, jlong a) { - LOG_API("nProgramBindSampler, con(%p), vpf(%p), slot(%i), a(%p)", (RsContext)con, (RsProgramFragment)vpf, slot, (RsSampler)a); + if (kLogApi) { + ALOGD("nProgramBindSampler, con(%p), vpf(%p), slot(%i), a(%p)", (RsContext)con, + (RsProgramFragment)vpf, slot, (RsSampler)a); + } rsProgramBindSampler((RsContext)con, (RsProgramFragment)vpf, slot, (RsSampler)a); } @@ -1378,7 +1559,9 @@ nProgramFragmentCreate(JNIEnv *_env, jobject _this, jlong con, jstring shader, const char ** nameArray = names.c_str(); size_t* sizeArray = names.c_str_len(); - LOG_API("nProgramFragmentCreate, con(%p), paramLen(%i)", (RsContext)con, paramLen); + if (kLogApi) { + ALOGD("nProgramFragmentCreate, con(%p), paramLen(%i)", (RsContext)con, paramLen); + } uintptr_t * paramPtr = (uintptr_t*) malloc(sizeof(uintptr_t) * paramLen); for(int i = 0; i < paramLen; ++i) { @@ -1404,7 +1587,9 @@ nProgramVertexCreate(JNIEnv *_env, jobject _this, jlong con, jstring shader, jlong *jParamPtr = _env->GetLongArrayElements(params, nullptr); jint paramLen = _env->GetArrayLength(params); - LOG_API("nProgramVertexCreate, con(%p), paramLen(%i)", (RsContext)con, paramLen); + if (kLogApi) { + ALOGD("nProgramVertexCreate, con(%p), paramLen(%i)", (RsContext)con, paramLen); + } int texCount = _env->GetArrayLength(texNames); AutoJavaStringArrayToUTF8 names(_env, texNames, texCount); @@ -1430,7 +1615,10 @@ nProgramVertexCreate(JNIEnv *_env, jobject _this, jlong con, jstring shader, static jlong nProgramRasterCreate(JNIEnv *_env, jobject _this, jlong con, jboolean pointSprite, jint cull) { - LOG_API("nProgramRasterCreate, con(%p), pointSprite(%i), cull(%i)", (RsContext)con, pointSprite, cull); + if (kLogApi) { + ALOGD("nProgramRasterCreate, con(%p), pointSprite(%i), cull(%i)", (RsContext)con, + pointSprite, cull); + } return (jlong)(uintptr_t)rsProgramRasterCreate((RsContext)con, pointSprite, (RsCullMode)cull); } @@ -1440,35 +1628,46 @@ nProgramRasterCreate(JNIEnv *_env, jobject _this, jlong con, jboolean pointSprit static void nContextBindRootScript(JNIEnv *_env, jobject _this, jlong con, jlong script) { - LOG_API("nContextBindRootScript, con(%p), script(%p)", (RsContext)con, (RsScript)script); + if (kLogApi) { + ALOGD("nContextBindRootScript, con(%p), script(%p)", (RsContext)con, (RsScript)script); + } rsContextBindRootScript((RsContext)con, (RsScript)script); } static void nContextBindProgramStore(JNIEnv *_env, jobject _this, jlong con, jlong pfs) { - LOG_API("nContextBindProgramStore, con(%p), pfs(%p)", (RsContext)con, (RsProgramStore)pfs); + if (kLogApi) { + ALOGD("nContextBindProgramStore, con(%p), pfs(%p)", (RsContext)con, (RsProgramStore)pfs); + } rsContextBindProgramStore((RsContext)con, (RsProgramStore)pfs); } static void nContextBindProgramFragment(JNIEnv *_env, jobject _this, jlong con, jlong pf) { - LOG_API("nContextBindProgramFragment, con(%p), pf(%p)", (RsContext)con, (RsProgramFragment)pf); + if (kLogApi) { + ALOGD("nContextBindProgramFragment, con(%p), pf(%p)", (RsContext)con, + (RsProgramFragment)pf); + } rsContextBindProgramFragment((RsContext)con, (RsProgramFragment)pf); } static void nContextBindProgramVertex(JNIEnv *_env, jobject _this, jlong con, jlong pf) { - LOG_API("nContextBindProgramVertex, con(%p), pf(%p)", (RsContext)con, (RsProgramVertex)pf); + if (kLogApi) { + ALOGD("nContextBindProgramVertex, con(%p), pf(%p)", (RsContext)con, (RsProgramVertex)pf); + } rsContextBindProgramVertex((RsContext)con, (RsProgramVertex)pf); } static void nContextBindProgramRaster(JNIEnv *_env, jobject _this, jlong con, jlong pf) { - LOG_API("nContextBindProgramRaster, con(%p), pf(%p)", (RsContext)con, (RsProgramRaster)pf); + if (kLogApi) { + ALOGD("nContextBindProgramRaster, con(%p), pf(%p)", (RsContext)con, (RsProgramRaster)pf); + } rsContextBindProgramRaster((RsContext)con, (RsProgramRaster)pf); } @@ -1479,7 +1678,9 @@ static jlong nSamplerCreate(JNIEnv *_env, jobject _this, jlong con, jint magFilter, jint minFilter, jint wrapS, jint wrapT, jint wrapR, jfloat aniso) { - LOG_API("nSamplerCreate, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nSamplerCreate, con(%p)", (RsContext)con); + } return (jlong)(uintptr_t)rsSamplerCreate((RsContext)con, (RsSamplerValue)magFilter, (RsSamplerValue)minFilter, @@ -1493,7 +1694,9 @@ nSamplerCreate(JNIEnv *_env, jobject _this, jlong con, jint magFilter, jint minF static jlong nPathCreate(JNIEnv *_env, jobject _this, jlong con, jint prim, jboolean isStatic, jlong _vtx, jlong _loop, jfloat q) { - LOG_API("nPathCreate, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nPathCreate, con(%p)", (RsContext)con); + } jlong id = (jlong)(uintptr_t)rsPathCreate((RsContext)con, (RsPathPrimitive)prim, isStatic, (RsAllocation)_vtx, @@ -1504,7 +1707,9 @@ nPathCreate(JNIEnv *_env, jobject _this, jlong con, jint prim, jboolean isStatic static jlong nMeshCreate(JNIEnv *_env, jobject _this, jlong con, jlongArray _vtx, jlongArray _idx, jintArray _prim) { - LOG_API("nMeshCreate, con(%p)", (RsContext)con); + if (kLogApi) { + ALOGD("nMeshCreate, con(%p)", (RsContext)con); + } jint vtxLen = _env->GetArrayLength(_vtx); jlong *jVtxPtr = _env->GetLongArrayElements(_vtx, nullptr); @@ -1539,7 +1744,9 @@ nMeshCreate(JNIEnv *_env, jobject _this, jlong con, jlongArray _vtx, jlongArray static jint nMeshGetVertexBufferCount(JNIEnv *_env, jobject _this, jlong con, jlong mesh) { - LOG_API("nMeshGetVertexBufferCount, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh); + if (kLogApi) { + ALOGD("nMeshGetVertexBufferCount, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh); + } jint vtxCount = 0; rsaMeshGetVertexBufferCount((RsContext)con, (RsMesh)mesh, &vtxCount); return vtxCount; @@ -1548,7 +1755,9 @@ nMeshGetVertexBufferCount(JNIEnv *_env, jobject _this, jlong con, jlong mesh) static jint nMeshGetIndexCount(JNIEnv *_env, jobject _this, jlong con, jlong mesh) { - LOG_API("nMeshGetIndexCount, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh); + if (kLogApi) { + ALOGD("nMeshGetIndexCount, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh); + } jint idxCount = 0; rsaMeshGetIndexCount((RsContext)con, (RsMesh)mesh, &idxCount); return idxCount; @@ -1557,7 +1766,9 @@ nMeshGetIndexCount(JNIEnv *_env, jobject _this, jlong con, jlong mesh) static void nMeshGetVertices(JNIEnv *_env, jobject _this, jlong con, jlong mesh, jlongArray _ids, jint numVtxIDs) { - LOG_API("nMeshGetVertices, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh); + if (kLogApi) { + ALOGD("nMeshGetVertices, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh); + } RsAllocation *allocs = (RsAllocation*)malloc((uint32_t)numVtxIDs * sizeof(RsAllocation)); rsaMeshGetVertices((RsContext)con, (RsMesh)mesh, allocs, (uint32_t)numVtxIDs); @@ -1573,7 +1784,9 @@ nMeshGetVertices(JNIEnv *_env, jobject _this, jlong con, jlong mesh, jlongArray static void nMeshGetIndices(JNIEnv *_env, jobject _this, jlong con, jlong mesh, jlongArray _idxIds, jintArray _primitives, jint numIndices) { - LOG_API("nMeshGetVertices, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh); + if (kLogApi) { + ALOGD("nMeshGetVertices, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh); + } RsAllocation *allocs = (RsAllocation*)malloc((uint32_t)numIndices * sizeof(RsAllocation)); uint32_t *prims= (uint32_t*)malloc((uint32_t)numIndices * sizeof(uint32_t)); diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index 4cca57f..0ec1aeb 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -3009,7 +3009,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<const ResourceFilter>& // We need to write one type chunk for each configuration for // which we have entries in this type. - const size_t NC = t->getUniqueConfigs().size(); + const size_t NC = t != NULL ? t->getUniqueConfigs().size() : 0; const size_t typeSize = sizeof(ResTable_type) + sizeof(uint32_t)*N; diff --git a/tools/aidl/aidl.cpp b/tools/aidl/aidl.cpp index 45dd23b..14c9f95 100644 --- a/tools/aidl/aidl.cpp +++ b/tools/aidl/aidl.cpp @@ -228,7 +228,8 @@ check_filename(const char* filename, const char* package, buffer_type* name) } #endif -#ifdef OS_CASE_SENSITIVE + // aidl assumes case-insensitivity on Mac Os and Windows. +#if defined(__linux__) valid = (expected == p); #else valid = !strcasecmp(expected.c_str(), p); |