am d070009e: am df6774c9: am 7c1cdbdd: am e23f8b8f: am 1f70863d: am 37b44969: Add support for writing byte arrays to parcels * commit 'd070009ecdb9e8c58ce5d1540d5bcba5587a0448': Add support for writing byte arrays to parcels
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index 8718bb6..55a36c2 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c
@@ -25,7 +25,7 @@ #include <sys/time.h> #include <sys/wait.h> #include <unistd.h> -#include <linux/capability.h> +#include <sys/capability.h> #include <linux/prctl.h> #include <cutils/properties.h>
diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c index 8f132d5..eaef3d4 100644 --- a/cmds/dumpstate/utils.c +++ b/cmds/dumpstate/utils.c
@@ -31,6 +31,7 @@ #include <sys/klog.h> #include <time.h> #include <unistd.h> +#include <sys/prctl.h> #include <cutils/debugger.h> #include <cutils/properties.h> @@ -199,6 +200,9 @@ const char *args[1024] = {command}; size_t arg; + /* make sure the child dies when dumpstate dies */ + prctl(PR_SET_PDEATHSIG, SIGKILL); + va_list ap; va_start(ap, command); if (title) printf("------ %s (%s", title, command);
diff --git a/include/android/bitmap.h b/include/android/bitmap.h index 5078277..6e18763 100644 --- a/include/android/bitmap.h +++ b/include/android/bitmap.h
@@ -24,11 +24,14 @@ extern "C" { #endif -#define ANDROID_BITMAP_RESUT_SUCCESS 0 +#define ANDROID_BITMAP_RESULT_SUCCESS 0 #define ANDROID_BITMAP_RESULT_BAD_PARAMETER -1 #define ANDROID_BITMAP_RESULT_JNI_EXCEPTION -2 #define ANDROID_BITMAP_RESULT_ALLOCATION_FAILED -3 +/* Backward compatibility: this macro used to be misspelled. */ +#define ANDROID_BITMAP_RESUT_SUCCESS ANDROID_BITMAP_RESULT_SUCCESS + enum AndroidBitmapFormat { ANDROID_BITMAP_FORMAT_NONE = 0, ANDROID_BITMAP_FORMAT_RGBA_8888 = 1,
diff --git a/include/gui/GLConsumer.h b/include/gui/GLConsumer.h new file mode 100644 index 0000000..d53b04a --- /dev/null +++ b/include/gui/GLConsumer.h
@@ -0,0 +1,46 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_GUI_CONSUMER_H +#define ANDROID_GUI_CONSUMER_H + +#include <gui/BufferQueue.h> +#include <gui/ConsumerBase.h> +#include <gui/ISurfaceTexture.h> + +namespace android { + +class GLConsumer : public ConsumerBase { +public: + GLConsumer(GLuint, bool = false, GLenum = 0, bool = false, const sp<BufferQueue>& = 0) : + ConsumerBase(0) {} + void incStrong(const void*) const {} + void decStrong(const void*) const {} + status_t updateTexImage() { return 0; } + void abandon() {} + sp<ISurfaceTexture> getBufferQueue() const { return 0; } + GLenum getCurrentTextureTarget() const { return 0; } + status_t setSynchronousMode(bool) { return 0; } + void getTransformMatrix(float[16]) {} + int64_t getTimestamp() {} + void setFrameAvailableListener(const wp<FrameAvailableListener>&) {} + sp<GraphicBuffer> getCurrentBuffer() const { return 0; } +}; + +}; // namespace android + +#endif // ANDROID_GUI_CONSUMER_H +
diff --git a/include/gui/Surface.h b/include/gui/Surface.h index 2288fe7..3411f0a 100644 --- a/include/gui/Surface.h +++ b/include/gui/Surface.h
@@ -121,6 +121,8 @@ explicit Surface(const sp<ISurfaceTexture>& st); + Surface (sp<BufferQueue>&) {} + static status_t writeToParcel(const sp<Surface>& control, Parcel* parcel); static sp<Surface> readFromParcel(const Parcel& data); @@ -134,6 +136,7 @@ // the lock/unlock APIs must be used from the same thread status_t lock(SurfaceInfo* info, Region* dirty = NULL); + int lock(ANativeWindow_Buffer*, ARect*) { return 0; } status_t unlockAndPost(); sp<IBinder> asBinder() const;
diff --git a/include/utils/Compat.h b/include/utils/Compat.h index 1819266..fb7748e 100644 --- a/include/utils/Compat.h +++ b/include/utils/Compat.h
@@ -39,4 +39,27 @@ #endif /* !HAVE_OFF64_T */ +#if HAVE_PRINTF_ZD +# define ZD "%zd" +# define ZD_TYPE ssize_t +#else +# define ZD "%ld" +# define ZD_TYPE long +#endif + +/* + * TEMP_FAILURE_RETRY is defined by some, but not all, versions of + * <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's + * not already defined, then define it here. + */ +#ifndef TEMP_FAILURE_RETRY +/* Used to retry syscalls that can return EINTR. */ +#define TEMP_FAILURE_RETRY(exp) ({ \ + typeof (exp) _rc; \ + do { \ + _rc = (exp); \ + } while (_rc == -1 && errno == EINTR); \ + _rc; }) +#endif + #endif /* __LIB_UTILS_COMPAT_H */
diff --git a/include/utils/LinearAllocator.h b/include/utils/LinearAllocator.h new file mode 100644 index 0000000..cd2521d --- /dev/null +++ b/include/utils/LinearAllocator.h
@@ -0,0 +1,42 @@ +/* + * Copyright 2012, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ANDROID_LINEARALLOCATOR_H +#define ANDROID_LINEARALLOCATOR_H + +#include <stddef.h> + +namespace android { + +class LinearAllocator { +public: + void* alloc(size_t size) { return 0; } + void rewindIfLastAlloc(void* ptr, size_t allocSize) {} + void dumpMemoryStats(const char* prefix = "") {} +}; + +}; // namespace android + +#endif // ANDROID_LINEARALLOCATOR_H
diff --git a/libs/binder/MemoryBase.cpp b/libs/binder/MemoryBase.cpp index 033066b..5c82330 100644 --- a/libs/binder/MemoryBase.cpp +++ b/libs/binder/MemoryBase.cpp
@@ -14,6 +14,7 @@ * limitations under the License. */ +#define LOG_TAG "MemoryBase" #include <stdlib.h> #include <stdint.h> @@ -44,3 +45,11 @@ // --------------------------------------------------------------------------- }; // namespace android + +// Backwards compatibility for libdatabase_sqlcipher (http://b/8253769). +extern "C" void _ZN7android10MemoryBaseC1ERKNS_2spINS_11IMemoryHeapEEEij(void*, void*, ssize_t, size_t); +extern "C" void _ZN7android10MemoryBaseC1ERKNS_2spINS_11IMemoryHeapEEElj(void* obj, void* h, long o, unsigned int size) { + _ZN7android10MemoryBaseC1ERKNS_2spINS_11IMemoryHeapEEEij(obj, h, o, size); + ALOGW("Using temporary compatibility workaround for usage of MemoryBase " + "private API. Please fix your application!"); +}
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index cb90b83..53b29a4 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp
@@ -638,11 +638,27 @@ return writeAligned(val); } +#if defined(__mips__) && defined(__mips_hard_float) + +status_t Parcel::writeDouble(double val) +{ + union { + double d; + unsigned long long ll; + } u; + u.d = val; + return writeAligned(u.ll); +} + +#else + status_t Parcel::writeDouble(double val) { return writeAligned(val); } +#endif + status_t Parcel::writeIntPtr(intptr_t val) { return writeAligned(val); @@ -973,17 +989,44 @@ return readAligned<float>(); } +#if defined(__mips__) && defined(__mips_hard_float) + +status_t Parcel::readDouble(double *pArg) const +{ + union { + double d; + unsigned long long ll; + } u; + status_t status; + status = readAligned(&u.ll); + *pArg = u.d; + return status; +} + +double Parcel::readDouble() const +{ + union { + double d; + unsigned long long ll; + } u; + u.ll = readAligned<unsigned long long>(); + return u.d; +} + +#else + status_t Parcel::readDouble(double *pArg) const { return readAligned(pArg); } - double Parcel::readDouble() const { return readAligned<double>(); } +#endif + status_t Parcel::readIntPtr(intptr_t *pArg) const { return readAligned(pArg);
diff --git a/libs/utils/ZipFileRO.cpp b/libs/utils/ZipFileRO.cpp index ef49c0f..a1bfedb 100644 --- a/libs/utils/ZipFileRO.cpp +++ b/libs/utils/ZipFileRO.cpp
@@ -20,6 +20,7 @@ #define LOG_TAG "zipro" //#define LOG_NDEBUG 0 #include <utils/Log.h> +#include <utils/Compat.h> #include <utils/ZipFileRO.h> #include <utils/misc.h> #include <utils/threads.h> @@ -32,14 +33,6 @@ #include <assert.h> #include <unistd.h> -#if HAVE_PRINTF_ZD -# define ZD "%zd" -# define ZD_TYPE ssize_t -#else -# define ZD "%ld" -# define ZD_TYPE long -#endif - /* * We must open binary files using open(path, ... | O_BINARY) under Windows. * Otherwise strange read errors will happen. @@ -48,21 +41,6 @@ # define O_BINARY 0 #endif -/* - * TEMP_FAILURE_RETRY is defined by some, but not all, versions of - * <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's - * not already defined, then define it here. - */ -#ifndef TEMP_FAILURE_RETRY -/* Used to retry syscalls that can return EINTR. */ -#define TEMP_FAILURE_RETRY(exp) ({ \ - typeof (exp) _rc; \ - do { \ - _rc = (exp); \ - } while (_rc == -1 && errno == EINTR); \ - _rc; }) -#endif - using namespace android; /*
diff --git a/libs/utils/ZipUtils.cpp b/libs/utils/ZipUtils.cpp index cf5467b..a43bbb0 100644 --- a/libs/utils/ZipUtils.cpp +++ b/libs/utils/ZipUtils.cpp
@@ -21,6 +21,7 @@ #define LOG_TAG "ziputil" #include <utils/Log.h> +#include <utils/Compat.h> #include <utils/ZipUtils.h> #include <utils/ZipFileRO.h> @@ -98,10 +99,11 @@ ALOGV("+++ reading %ld bytes (%ld left)\n", getSize, compRemaining); - int cc = read(fd, readBuf, getSize); - if (cc != (int) getSize) { - ALOGD("inflate read failed (%d vs %ld)\n", - cc, getSize); + int cc = TEMP_FAILURE_RETRY(read(fd, readBuf, getSize)); + if (cc < 0) { + ALOGW("inflate read failed: %s", strerror(errno)); + } else if (cc != (int) getSize) { + ALOGW("inflate read failed (%d vs %ld)", cc, getSize); goto z_bail; }
diff --git a/libs/utils/tests/Android.mk b/libs/utils/tests/Android.mk index 0a5b379..5b2b5b1 100644 --- a/libs/utils/tests/Android.mk +++ b/libs/utils/tests/Android.mk
@@ -4,42 +4,30 @@ # Build the unit tests. test_src_files := \ - BasicHashtable_test.cpp \ - BlobCache_test.cpp \ - Looper_test.cpp \ - String8_test.cpp \ - Unicode_test.cpp \ - Vector_test.cpp \ - ZipFileRO_test.cpp + BasicHashtable_test.cpp \ + BlobCache_test.cpp \ + Looper_test.cpp \ + String8_test.cpp \ + Unicode_test.cpp \ + Vector_test.cpp \ + ZipFileRO_test.cpp shared_libraries := \ - libz \ - liblog \ - libcutils \ - libutils \ - libstlport + libz \ + liblog \ + libcutils \ + libutils \ + libstlport static_libraries := \ - libgtest \ - libgtest_main - -c_includes := \ - external/zlib \ - external/icu4c/common \ - bionic \ - bionic/libstdc++/include \ - external/gtest/include \ - external/stlport/stlport - -module_tags := eng tests + libgtest \ + libgtest_main $(foreach file,$(test_src_files), \ $(eval include $(CLEAR_VARS)) \ $(eval LOCAL_SHARED_LIBRARIES := $(shared_libraries)) \ $(eval LOCAL_STATIC_LIBRARIES := $(static_libraries)) \ - $(eval LOCAL_C_INCLUDES := $(c_includes)) \ $(eval LOCAL_SRC_FILES := $(file)) \ $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \ - $(eval LOCAL_MODULE_TAGS := $(module_tags)) \ - $(eval include $(BUILD_EXECUTABLE)) \ + $(eval include $(BUILD_NATIVE_TEST)) \ )
diff --git a/opengl/include/GLES2/gl2.h b/opengl/include/GLES2/gl2.h index e1d3b87..c139c25 100644 --- a/opengl/include/GLES2/gl2.h +++ b/opengl/include/GLES2/gl2.h
@@ -528,7 +528,7 @@ GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); -GL_APICALL int GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); GL_APICALL GLenum GL_APIENTRY glGetError (void); @@ -547,7 +547,7 @@ GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); -GL_APICALL int GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer);
diff --git a/opengl/libagl/Android.mk b/opengl/libagl/Android.mk index 639c4d7..9b8d3fe 100644 --- a/opengl/libagl/Android.mk +++ b/opengl/libagl/Android.mk
@@ -34,16 +34,14 @@ LOCAL_CFLAGS += -fstrict-aliasing endif -ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true) - LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER +ifeq ($(TARGET_ARCH),mips) + LOCAL_SRC_FILES += arch-$(TARGET_ARCH)/fixed_asm.S + LOCAL_CFLAGS += -fstrict-aliasing + # The graphics code can generate division by zero + LOCAL_CFLAGS += -mno-check-zero-division endif # we need to access the private Bionic header <bionic_tls.h> -# on ARM platforms, we need to mirror the ARCH_ARM_HAVE_TLS_REGISTER -# behavior from the bionic Android.mk file -ifeq ($(TARGET_ARCH)-$(ARCH_ARM_HAVE_TLS_REGISTER),arm-true) - LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER -endif LOCAL_C_INCLUDES += bionic/libc/private LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
diff --git a/opengl/libagl/arch-mips/fixed_asm.S b/opengl/libagl/arch-mips/fixed_asm.S new file mode 100644 index 0000000..e1a53bc --- /dev/null +++ b/opengl/libagl/arch-mips/fixed_asm.S
@@ -0,0 +1,61 @@ +/* libs/opengles/arch-mips/fixed_asm.S +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + + + .text + .align + +/* + * this version rounds-to-nearest and saturates numbers + * outside the range (but not NaNs). + */ + + .global gglFloatToFixed + .ent gglFloatToFixed + .type gglFloatToFixed, @function +gglFloatToFixed: +#if !defined(__mips_soft_float) + mfc1 $a0,$f12 +#endif + srl $t0,$a0,31 /* t0 <- sign bit */ + srl $t1,$a0,23 + andi $t1,$t1,0xff /* get the e */ + li $t2,0x8e + subu $t1,$t2,$t1 /* t1=127+15-e */ + blez $t1,0f /* t1<=0? */ + sll $t2,$a0,8 /* mantissa<<8 */ + lui $t3,0x8000 + or $t2,$t2,$t3 /* add the missing 1 */ + subu $t1,$t1,1 + srl $v0,$t2,$t1 + sltiu $t3,$t1,32 /* t3=1 if t1<32, else t3=0. t1>=32 means the float value is too small. */ + andi $t4,$v0,0x1 + srl $v0,$v0,1 /* scale to 16.16 */ + addu $v0,$v0,$t4 /* round-to-nearest */ + subu $t2,$zero,$v0 + movn $v0,$t2,$t0 /* if negative? */ + or $t1,$a0,$zero /* a0=0? */ + movz $v0,$zero,$t1 + movz $v0,$zero,$t3 /* t3=0 then res=0 */ + jr $ra +0: + lui $t1,0x8000 + and $v0,$a0,$t1 /* keep only the sign bit */ + li $t1,0x7fffffff + movz $v0,$t1,$t0 /* positive, maximum value */ + jr $ra + .end gglFloatToFixed
diff --git a/opengl/libagl/fp.cpp b/opengl/libagl/fp.cpp index ae5f1fe..aea4449 100644 --- a/opengl/libagl/fp.cpp +++ b/opengl/libagl/fp.cpp
@@ -19,7 +19,7 @@ // ---------------------------------------------------------------------------- -#if !defined(__arm__) +#if !defined(__arm__) && !defined(__mips__) GGLfixed gglFloatToFixed(float v) { return GGLfixed(floorf(v * 65536.0f + 0.5f)); }
diff --git a/opengl/libagl/matrix.h b/opengl/libagl/matrix.h index c9a38a9..5bd717a 100644 --- a/opengl/libagl/matrix.h +++ b/opengl/libagl/matrix.h
@@ -74,6 +74,30 @@ ); return r; +#elif defined(__mips__) + + GLfixed res; + int32_t t1,t2,t3; + asm( + "mult %[a], %[a] \r\n" + "li %[res],0x8000 \r\n" + "madd %[b],%[b] \r\n" + "move %[t3],$zero \r\n" + "madd %[c],%[c] \r\n" + "mflo %[t1]\r\n" + "mfhi %[t2]\r\n" + "addu %[t1],%[res],%[t1]\r\n" /*add 0x8000*/ + "sltu %[t3],%[t1],%[res]\r\n" + "addu %[t2],%[t2],%[t3]\r\n" + "srl %[res],%[t1],16\r\n" + "sll %[t2],%[t2],16\r\n" + "or %[res],%[res],%[t2]\r\n" + : [res]"=&r"(res),[t1]"=&r"(t1),[t2]"=&r"(t2),[t3]"=&r"(t3) + : [a] "r" (a),[b] "r" (b),[c] "r" (c) + : "%hi","%lo" + ); + return res; + #else return (( int64_t(a)*a + @@ -136,6 +160,26 @@ ); return r; +#elif defined(__mips__) + + GLfixed res; + int32_t t1,t2; + asm( + "mult %[a0],%[b0] \r\n" + "madd %[a1],%[b1] \r\n" + "madd %[a2],%[b2] \r\n" + "mflo %[t2]\r\n" + "mfhi %[t1]\r\n" + "srl %[t2],%[t2],16\r\n" + "sll %[t1],%[t1],16\r\n" + "or %[t2],%[t2],%[t1]\r\n" + "addu %[res],%[t2],%[c]" + : [res]"=&r"(res),[t1]"=&r"(t1),[t2]"=&r"(t2) + : [a0] "r" (a0),[b0] "r" (b0),[a1] "r" (a1),[b1] "r" (b1),[a2] "r" (a2),[b2] "r" (b2),[c] "r" (c) + : "%hi","%lo" + ); + return res; + #else return (( int64_t(a0)*b0 +
diff --git a/opengl/libs/Android.mk b/opengl/libs/Android.mk index 31bfcd7..d025ae8 100644 --- a/opengl/libs/Android.mk +++ b/opengl/libs/Android.mk
@@ -23,11 +23,6 @@ LOCAL_MODULE:= libEGL LOCAL_LDFLAGS += -Wl,--exclude-libs=ALL LOCAL_SHARED_LIBRARIES += libdl -# Bionic's private TLS header relies on the ARCH_ARM_HAVE_TLS_REGISTER to -# select the appropriate TLS codepath -ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true) - LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER -endif # we need to access the private Bionic header <bionic_tls.h> LOCAL_C_INCLUDES += bionic/libc/private @@ -49,10 +44,6 @@ LOCAL_CFLAGS += -DSYSTEMUI_PBSIZE_HACK=1 endif -ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true) - LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER -endif - ifneq ($(MAX_EGL_CACHE_ENTRY_SIZE),) LOCAL_CFLAGS += -DMAX_EGL_CACHE_ENTRY_SIZE=$(MAX_EGL_CACHE_ENTRY_SIZE) endif @@ -100,19 +91,12 @@ LOCAL_SHARED_LIBRARIES += libdl # we need to access the private Bionic header <bionic_tls.h> -ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true) - LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER -endif LOCAL_C_INCLUDES += bionic/libc/private LOCAL_CFLAGS += -DLOG_TAG=\"libGLESv1\" LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES LOCAL_CFLAGS += -fvisibility=hidden -ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true) - LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER -endif - include $(BUILD_SHARED_LIBRARY) @@ -132,19 +116,12 @@ LOCAL_SHARED_LIBRARIES += libdl # we need to access the private Bionic header <bionic_tls.h> -ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true) - LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER -endif LOCAL_C_INCLUDES += bionic/libc/private LOCAL_CFLAGS += -DLOG_TAG=\"libGLESv2\" LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES LOCAL_CFLAGS += -fvisibility=hidden -ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true) - LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER -endif - include $(BUILD_SHARED_LIBRARY) ###############################################################################
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index 23e89da..065faf2 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp
@@ -760,8 +760,8 @@ egl_connection_t* const cnx = &gEGLImpl; if (cnx->dso && cnx->egl.eglGetProcAddress) { - found = true; // Extensions are independent of the bound context + addr = cnx->hooks[egl_connection_t::GLESv1_INDEX]->ext.extensions[slot] = cnx->hooks[egl_connection_t::GLESv2_INDEX]->ext.extensions[slot] = #if EGL_TRACE @@ -769,10 +769,13 @@ gHooksTrace.ext.extensions[slot] = #endif cnx->egl.eglGetProcAddress(procname); + if (addr) found = true; } if (found) { +#if USE_FAST_TLS_KEY addr = gExtensionForwarders[slot]; +#endif sGLExtentionMap.add(name, addr); sGLExtentionSlot++; } @@ -1171,11 +1174,12 @@ const egl_display_ptr dp = validate_display(dpy); if (!dp) return EGL_FALSE; + EGLBoolean result = EGL_FALSE; egl_connection_t* const cnx = &gEGLImpl; if (cnx->dso && cnx->egl.eglDestroyImageKHR) { - cnx->egl.eglDestroyImageKHR(dp->disp.dpy, img); + result = cnx->egl.eglDestroyImageKHR(dp->disp.dpy, img); } - return EGL_TRUE; + return result; } // ----------------------------------------------------------------------------
diff --git a/opengl/libs/EGL/getProcAddress.cpp b/opengl/libs/EGL/getProcAddress.cpp index 8dcf38d..d23da7a 100644 --- a/opengl/libs/EGL/getProcAddress.cpp +++ b/opengl/libs/EGL/getProcAddress.cpp
@@ -37,14 +37,9 @@ #if USE_FAST_TLS_KEY - #ifdef HAVE_ARM_TLS_REGISTER - #define GET_TLS(reg) \ - "mrc p15, 0, " #reg ", c13, c0, 3 \n" - #else - #define GET_TLS(reg) \ - "mov " #reg ", #0xFFFF0FFF \n" \ - "ldr " #reg ", [" #reg ", #-15] \n" - #endif + #if defined(__arm__) + + #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n" #define API_ENTRY(_api) __attribute__((naked)) _api @@ -64,6 +59,41 @@ : \ ); + #elif defined(__mips__) + + #define API_ENTRY(_api) __attribute__((noinline)) _api + + #define CALL_GL_EXTENSION_API(_api, ...) \ + register unsigned int t0 asm("t0"); \ + register unsigned int fn asm("t1"); \ + register unsigned int tls asm("v1"); \ + asm volatile( \ + ".set push\n\t" \ + ".set noreorder\n\t" \ + ".set mips32r2\n\t" \ + "rdhwr %[tls], $29\n\t" \ + "lw %[t0], %[OPENGL_API](%[tls])\n\t" \ + "beqz %[t0], 1f\n\t" \ + " move %[fn], $ra\n\t" \ + "lw %[fn], %[API](%[t0])\n\t" \ + "movz %[fn], $ra, %[fn]\n\t" \ + "1:\n\t" \ + "j %[fn]\n\t" \ + " nop\n\t" \ + ".set pop\n\t" \ + : [fn] "=c"(fn), \ + [tls] "=&r"(tls), \ + [t0] "=&r"(t0) \ + : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4), \ + [API] "I"(__builtin_offsetof(gl_hooks_t, \ + ext.extensions[_api])) \ + : \ + ); + + #else + #error Unsupported architecture + #endif + #define GL_EXTENSION_NAME(_n) __glExtFwd##_n #define GL_EXTENSION(_n) \
diff --git a/opengl/libs/GLES2/gl2.cpp b/opengl/libs/GLES2/gl2.cpp index 55ef499..fb890fc 100644 --- a/opengl/libs/GLES2/gl2.cpp +++ b/opengl/libs/GLES2/gl2.cpp
@@ -41,14 +41,9 @@ #if USE_FAST_TLS_KEY - #ifdef HAVE_ARM_TLS_REGISTER - #define GET_TLS(reg) \ - "mrc p15, 0, " #reg ", c13, c0, 3 \n" - #else - #define GET_TLS(reg) \ - "mov " #reg ", #0xFFFF0FFF \n" \ - "ldr " #reg ", [" #reg ", #-15] \n" - #endif + #if defined(__arm__) + + #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n" #define API_ENTRY(_api) __attribute__((naked)) _api @@ -66,6 +61,44 @@ : \ ); + #elif defined(__mips__) + + #define API_ENTRY(_api) __attribute__((noinline)) _api + + #define CALL_GL_API(_api, ...) \ + register unsigned int t0 asm("t0"); \ + register unsigned int fn asm("t1"); \ + register unsigned int tls asm("v1"); \ + register unsigned int v0 asm("v0"); \ + asm volatile( \ + ".set push\n\t" \ + ".set noreorder\n\t" \ + ".set mips32r2\n\t" \ + "rdhwr %[tls], $29\n\t" \ + "lw %[t0], %[OPENGL_API](%[tls])\n\t" \ + "beqz %[t0], 1f\n\t" \ + " move %[fn],$ra\n\t" \ + "lw %[fn], %[API](%[t0])\n\t" \ + "movz %[fn], $ra, %[fn]\n\t" \ + "1:\n\t" \ + "j %[fn]\n\t" \ + " move %[v0], $0\n\t" \ + ".set pop\n\t" \ + : [fn] "=c"(fn), \ + [tls] "=&r"(tls), \ + [t0] "=&r"(t0), \ + [v0] "=&r"(v0) \ + : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4), \ + [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \ + : \ + ); + + #else + + #error Unsupported architecture + + #endif + #define CALL_GL_API_RETURN(_api, ...) \ CALL_GL_API(_api, __VA_ARGS__) \ return 0; // placate gcc's warnings. never reached.
diff --git a/opengl/libs/GLES2/gl2_api.in b/opengl/libs/GLES2/gl2_api.in index 9a89a52..cccf46c 100644 --- a/opengl/libs/GLES2/gl2_api.in +++ b/opengl/libs/GLES2/gl2_api.in
@@ -169,7 +169,7 @@ void API_ENTRY(glGetAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { CALL_GL_API(glGetAttachedShaders, program, maxcount, count, shaders); } -int API_ENTRY(glGetAttribLocation)(GLuint program, const GLchar* name) { +GLint API_ENTRY(glGetAttribLocation)(GLuint program, const GLchar* name) { CALL_GL_API_RETURN(glGetAttribLocation, program, name); } void API_ENTRY(glGetBooleanv)(GLenum pname, GLboolean* params) { @@ -226,7 +226,7 @@ void API_ENTRY(glGetUniformiv)(GLuint program, GLint location, GLint* params) { CALL_GL_API(glGetUniformiv, program, location, params); } -int API_ENTRY(glGetUniformLocation)(GLuint program, const GLchar* name) { +GLint API_ENTRY(glGetUniformLocation)(GLuint program, const GLchar* name) { CALL_GL_API_RETURN(glGetUniformLocation, program, name); } void API_ENTRY(glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params) {
diff --git a/opengl/libs/GLES_CM/gl.cpp b/opengl/libs/GLES_CM/gl.cpp index adcb60d..bd08942 100644 --- a/opengl/libs/GLES_CM/gl.cpp +++ b/opengl/libs/GLES_CM/gl.cpp
@@ -97,14 +97,9 @@ #if USE_FAST_TLS_KEY && !CHECK_FOR_GL_ERRORS - #ifdef HAVE_ARM_TLS_REGISTER - #define GET_TLS(reg) \ - "mrc p15, 0, " #reg ", c13, c0, 3 \n" - #else - #define GET_TLS(reg) \ - "mov " #reg ", #0xFFFF0FFF \n" \ - "ldr " #reg ", [" #reg ", #-15] \n" - #endif + #if defined(__arm__) + + #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n" #define API_ENTRY(_api) __attribute__((naked)) _api @@ -122,6 +117,42 @@ : \ ); + #elif defined(__mips__) + + #define API_ENTRY(_api) __attribute__((noinline)) _api + + #define CALL_GL_API(_api, ...) \ + register unsigned int t0 asm("t0"); \ + register unsigned int fn asm("t1"); \ + register unsigned int tls asm("v1"); \ + register unsigned int v0 asm("v0"); \ + asm volatile( \ + ".set push\n\t" \ + ".set noreorder\n\t" \ + ".set mips32r2\n\t" \ + "rdhwr %[tls], $29\n\t" \ + "lw %[t0], %[OPENGL_API](%[tls])\n\t" \ + "beqz %[t0], 1f\n\t" \ + " move %[fn], $ra\n\t" \ + "lw %[fn], %[API](%[t0])\n\t" \ + "movz %[fn], $ra, %[fn]\n\t" \ + "1:\n\t" \ + "j %[fn]\n\t" \ + " move %[v0], $0\n\t" \ + ".set pop\n\t" \ + : [fn] "=c"(fn), \ + [tls] "=&r"(tls), \ + [t0] "=&r"(t0), \ + [v0] "=&r"(v0) \ + : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4), \ + [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \ + : \ + ); + + #else + #error Unsupported architecture + #endif + #define CALL_GL_API_RETURN(_api, ...) \ CALL_GL_API(_api, __VA_ARGS__) \ return 0; // placate gcc's warnings. never reached.
diff --git a/opengl/libs/GLES_trace/Android.mk b/opengl/libs/GLES_trace/Android.mk index 465b6b2..9dec020 100644 --- a/opengl/libs/GLES_trace/Android.mk +++ b/opengl/libs/GLES_trace/Android.mk
@@ -24,18 +24,9 @@ LOCAL_STATIC_LIBRARIES := libprotobuf-cpp-2.3.0-lite liblzf LOCAL_SHARED_LIBRARIES := libcutils libutils libstlport -ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true) - LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER -endif - LOCAL_CFLAGS += -DLOG_TAG=\"libGLES_trace\" # we need to access the private Bionic header <bionic_tls.h> -# on ARM platforms, we need to mirror the ARCH_ARM_HAVE_TLS_REGISTER -# behavior from the bionic Android.mk file -ifeq ($(TARGET_ARCH)-$(ARCH_ARM_HAVE_TLS_REGISTER),arm-true) - LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER -endif LOCAL_C_INCLUDES += bionic/libc/private LOCAL_MODULE:= libGLES_trace
diff --git a/opengl/libs/GLES_trace/src/gltrace_api.cpp b/opengl/libs/GLES_trace/src/gltrace_api.cpp index cef6cbb..2ae4b11 100644 --- a/opengl/libs/GLES_trace/src/gltrace_api.cpp +++ b/opengl/libs/GLES_trace/src/gltrace_api.cpp
@@ -2214,7 +2214,7 @@ glContext->traceGLMessage(&glmsg); } -int GLTrace_glGetAttribLocation(GLuint program, const GLchar* name) { +GLint GLTrace_glGetAttribLocation(GLuint program, const GLchar* name) { GLMessage glmsg; GLTraceContext *glContext = getGLTraceContext(); @@ -2235,7 +2235,7 @@ // call function nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC); nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD); - int retValue = glContext->hooks->gl.glGetAttribLocation(program, name); + GLint retValue = glContext->hooks->gl.glGetAttribLocation(program, name); nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD); nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC); @@ -2996,7 +2996,7 @@ glContext->traceGLMessage(&glmsg); } -int GLTrace_glGetUniformLocation(GLuint program, const GLchar* name) { +GLint GLTrace_glGetUniformLocation(GLuint program, const GLchar* name) { GLMessage glmsg; GLTraceContext *glContext = getGLTraceContext(); @@ -3017,7 +3017,7 @@ // call function nsecs_t wallStartTime = systemTime(SYSTEM_TIME_MONOTONIC); nsecs_t threadStartTime = systemTime(SYSTEM_TIME_THREAD); - int retValue = glContext->hooks->gl.glGetUniformLocation(program, name); + GLint retValue = glContext->hooks->gl.glGetUniformLocation(program, name); nsecs_t threadEndTime = systemTime(SYSTEM_TIME_THREAD); nsecs_t wallEndTime = systemTime(SYSTEM_TIME_MONOTONIC);
diff --git a/opengl/libs/GLES_trace/src/gltrace_api.h b/opengl/libs/GLES_trace/src/gltrace_api.h index debcac0..309afcb 100644 --- a/opengl/libs/GLES_trace/src/gltrace_api.h +++ b/opengl/libs/GLES_trace/src/gltrace_api.h
@@ -78,7 +78,7 @@ void GLTrace_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); void GLTrace_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); void GLTrace_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); -int GLTrace_glGetAttribLocation(GLuint program, const GLchar* name); +GLint GLTrace_glGetAttribLocation(GLuint program, const GLchar* name); void GLTrace_glGetBooleanv(GLenum pname, GLboolean* params); void GLTrace_glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params); GLenum GLTrace_glGetError(void); @@ -97,7 +97,7 @@ void GLTrace_glGetTexParameteriv(GLenum target, GLenum pname, GLint* params); void GLTrace_glGetUniformfv(GLuint program, GLint location, GLfloat* params); void GLTrace_glGetUniformiv(GLuint program, GLint location, GLint* params); -int GLTrace_glGetUniformLocation(GLuint program, const GLchar* name); +GLint GLTrace_glGetUniformLocation(GLuint program, const GLchar* name); void GLTrace_glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); void GLTrace_glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); void GLTrace_glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer);
diff --git a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp index 1bd790e..36ae314 100644 --- a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp +++ b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
@@ -341,7 +341,7 @@ /** Given a glGetActive[Uniform|Attrib] call, obtain the location * of the variable of given name in the call. */ -int getShaderVariableLocation(GLTraceContext *context, GLMessage *glmsg, GLchar *name) { +GLint getShaderVariableLocation(GLTraceContext *context, GLMessage *glmsg, GLchar *name) { GLMessage_Function func = glmsg->function(); if (func != GLMessage::glGetActiveAttrib && func != GLMessage::glGetActiveUniform) { return -1; @@ -374,7 +374,7 @@ // In order to make things simpler for the debugger, we also pass // a hidden location argument that stores the actual location. // append the location value to the end of the argument list - int location = getShaderVariableLocation(context, glmsg, (GLchar*)pointersToFixup[3]); + GLint location = getShaderVariableLocation(context, glmsg, (GLchar*)pointersToFixup[3]); GLMessage_DataType *arg_location = glmsg->add_args(); arg_location->set_isarray(false); arg_location->set_type(GLMessage::DataType::INT);
diff --git a/opengl/libs/entries.in b/opengl/libs/entries.in index 6316d78..b9a51a4 100644 --- a/opengl/libs/entries.in +++ b/opengl/libs/entries.in
@@ -160,7 +160,7 @@ GL_ENTRY(void, glGetActiveAttrib, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) GL_ENTRY(void, glGetActiveUniform, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) GL_ENTRY(void, glGetAttachedShaders, GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) -GL_ENTRY(int, glGetAttribLocation, GLuint program, const GLchar* name) +GL_ENTRY(GLint, glGetAttribLocation, GLuint program, const GLchar* name) GL_ENTRY(void, glGetBooleanv, GLenum pname, GLboolean *params) GL_ENTRY(void, glGetBufferParameteriv, GLenum target, GLenum pname, GLint *params) GL_ENTRY(void, glGetBufferPointervOES, GLenum target, GLenum pname, GLvoid ** params) @@ -218,7 +218,7 @@ GL_ENTRY(void, glGetTexParameteriv, GLenum target, GLenum pname, GLint *params) GL_ENTRY(void, glGetTexParameterxv, GLenum target, GLenum pname, GLfixed *params) GL_ENTRY(void, glGetTexParameterxvOES, GLenum target, GLenum pname, GLfixed *params) -GL_ENTRY(int, glGetUniformLocation, GLuint program, const GLchar* name) +GL_ENTRY(GLint, glGetUniformLocation, GLuint program, const GLchar* name) GL_ENTRY(void, glGetUniformfv, GLuint program, GLint location, GLfloat* params) GL_ENTRY(void, glGetUniformiv, GLuint program, GLint location, GLint* params) GL_ENTRY(void, glGetVertexAttribPointerv, GLuint index, GLenum pname, GLvoid** pointer)
diff --git a/opengl/libs/hooks.h b/opengl/libs/hooks.h index 8b1b389..e0ceb60 100644 --- a/opengl/libs/hooks.h +++ b/opengl/libs/hooks.h
@@ -30,7 +30,7 @@ #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> -#if !defined(__arm__) +#if !defined(__arm__) && !defined(__mips__) #define USE_SLOW_BINDING 1 #else #define USE_SLOW_BINDING 0
diff --git a/opengl/libs/trace.in b/opengl/libs/trace.in index a5c5c84..e89e456 100644 --- a/opengl/libs/trace.in +++ b/opengl/libs/trace.in
@@ -160,7 +160,7 @@ TRACE_GL_VOID(glGetActiveAttrib, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name), (program, index, bufsize, length, size, type, name), 7, "GLuint", program, "GLuint", index, "GLsizei", bufsize, "GLsizei*", length, "GLint*", size, "GLenum*", type, "GLchar*", name) TRACE_GL_VOID(glGetActiveUniform, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name), (program, index, bufsize, length, size, type, name), 7, "GLuint", program, "GLuint", index, "GLsizei", bufsize, "GLsizei*", length, "GLint*", size, "GLenum*", type, "GLchar*", name) TRACE_GL_VOID(glGetAttachedShaders, (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders), (program, maxcount, count, shaders), 4, "GLuint", program, "GLsizei", maxcount, "GLsizei*", count, "GLuint*", shaders) -TRACE_GL(int, glGetAttribLocation, (GLuint program, const GLchar* name), (program, name), 2, "GLuint", program, "const GLchar*", name) +TRACE_GL(GLint, glGetAttribLocation, (GLuint program, const GLchar* name), (program, name), 2, "GLuint", program, "const GLchar*", name) TRACE_GL_VOID(glGetBooleanv, (GLenum pname, GLboolean *params), (pname, params), 2, "GLenum", pname, "GLboolean *", params) TRACE_GL_VOID(glGetBufferParameteriv, (GLenum target, GLenum pname, GLint *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params) TRACE_GL_VOID(glGetBufferPointervOES, (GLenum target, GLenum pname, GLvoid ** params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLvoid **", params) @@ -218,7 +218,7 @@ TRACE_GL_VOID(glGetTexParameteriv, (GLenum target, GLenum pname, GLint *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLint *", params) TRACE_GL_VOID(glGetTexParameterxv, (GLenum target, GLenum pname, GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLfixed *", params) TRACE_GL_VOID(glGetTexParameterxvOES, (GLenum target, GLenum pname, GLfixed *params), (target, pname, params), 3, "GLenum", target, "GLenum", pname, "GLfixed *", params) -TRACE_GL(int, glGetUniformLocation, (GLuint program, const GLchar* name), (program, name), 2, "GLuint", program, "const GLchar*", name) +TRACE_GL(GLint, glGetUniformLocation, (GLuint program, const GLchar* name), (program, name), 2, "GLuint", program, "const GLchar*", name) TRACE_GL_VOID(glGetUniformfv, (GLuint program, GLint location, GLfloat* params), (program, location, params), 3, "GLuint", program, "GLint", location, "GLfloat*", params) TRACE_GL_VOID(glGetUniformiv, (GLuint program, GLint location, GLint* params), (program, location, params), 3, "GLuint", program, "GLint", location, "GLint*", params) TRACE_GL_VOID(glGetVertexAttribPointerv, (GLuint index, GLenum pname, GLvoid** pointer), (index, pname, pointer), 3, "GLuint", index, "GLenum", pname, "GLvoid**", pointer)
diff --git a/opengl/tests/gl2_jni/Android.mk b/opengl/tests/gl2_jni/Android.mk index 5d90ff6..25187c9 100644 --- a/opengl/tests/gl2_jni/Android.mk +++ b/opengl/tests/gl2_jni/Android.mk
@@ -30,7 +30,7 @@ # Optional tag would mean it doesn't get installed by default LOCAL_MODULE_TAGS := optional -LOCAL_CFLAGS := -Werror +LOCAL_CFLAGS := -Werror -Wno-error=unused-parameter LOCAL_SRC_FILES:= \ gl_code.cpp
diff --git a/opengl/tests/gl_jni/Android.mk b/opengl/tests/gl_jni/Android.mk index 3d20e72..80b4bac 100644 --- a/opengl/tests/gl_jni/Android.mk +++ b/opengl/tests/gl_jni/Android.mk
@@ -30,7 +30,7 @@ # Optional tag would mean it doesn't get installed by default LOCAL_MODULE_TAGS := optional -LOCAL_CFLAGS := -Werror +LOCAL_CFLAGS := -Werror -Wno-error=unused-parameter LOCAL_SRC_FILES:= \ gl_code.cpp
diff --git a/opengl/tests/gl_perf/fill_common.cpp b/opengl/tests/gl_perf/fill_common.cpp index 389381f..fefedc0 100644 --- a/opengl/tests/gl_perf/fill_common.cpp +++ b/opengl/tests/gl_perf/fill_common.cpp
@@ -189,7 +189,7 @@ } static void randUniform(int pgm, const char *var) { - int loc = glGetUniformLocation(pgm, var); + GLint loc = glGetUniformLocation(pgm, var); if (loc >= 0) { float x = ((float)rand()) / RAND_MAX; float y = ((float)rand()) / RAND_MAX; @@ -211,7 +211,7 @@ startTimer(); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); for (uint32_t ct=0; ct < passCount; ct++) { - int loc = glGetUniformLocation(pgm, "u_texOff"); + GLint loc = glGetUniformLocation(pgm, "u_texOff"); glUniform2f(loc, ((float)ct) / passCount, ((float)ct) / 2.f / passCount); randUniform(pgm, "u_color"); @@ -271,7 +271,7 @@ printf("error running test\n"); return; } - int loc = glGetUniformLocation(pgm, "u_tex0"); + GLint loc = glGetUniformLocation(pgm, "u_tex0"); if (loc >= 0) glUniform1i(loc, 0); loc = glGetUniformLocation(pgm, "u_tex1"); if (loc >= 0) glUniform1i(loc, 1);
diff --git a/opengl/tests/gl_perfapp/Android.mk b/opengl/tests/gl_perfapp/Android.mk index 65e50e9..45a5516 100644 --- a/opengl/tests/gl_perfapp/Android.mk +++ b/opengl/tests/gl_perfapp/Android.mk
@@ -33,7 +33,7 @@ # Optional tag would mean it doesn't get installed by default LOCAL_MODULE_TAGS := optional -LOCAL_CFLAGS := -Werror +LOCAL_CFLAGS := -Werror -Wno-error=unused-parameter LOCAL_SRC_FILES:= \ gl_code.cpp
diff --git a/opengl/tests/gldual/Android.mk b/opengl/tests/gldual/Android.mk index b4b378e..42094c8 100644 --- a/opengl/tests/gldual/Android.mk +++ b/opengl/tests/gldual/Android.mk
@@ -30,7 +30,7 @@ # Optional tag would mean it doesn't get installed by default LOCAL_MODULE_TAGS := optional -LOCAL_CFLAGS := -Werror +LOCAL_CFLAGS := -Werror -Wno-error=unused-parameter LOCAL_SRC_FILES:= \ gl_code.cpp
diff --git a/opengl/tools/glgen/specs/gles11/GLES20.spec b/opengl/tools/glgen/specs/gles11/GLES20.spec index ee88f59..dda746e 100644 --- a/opengl/tools/glgen/specs/gles11/GLES20.spec +++ b/opengl/tools/glgen/specs/gles11/GLES20.spec
@@ -56,7 +56,7 @@ void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) void glGetActiveUniform ( GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, char *name ) void glGetAttachedShaders ( GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders ) -int glGetAttribLocation ( GLuint program, const char *name ) +GLint glGetAttribLocation ( GLuint program, const char *name ) void glGetBooleanv ( GLenum pname, GLboolean *params ) void glGetBufferParameteriv ( GLenum target, GLenum pname, GLint *params ) GLenum glGetError ( void ) @@ -75,7 +75,7 @@ void glGetTexParameteriv ( GLenum target, GLenum pname, GLint *params ) void glGetUniformfv ( GLuint program, GLint location, GLfloat *params ) void glGetUniformiv ( GLuint program, GLint location, GLint *params ) -int glGetUniformLocation ( GLuint program, const char *name ) +GLint glGetUniformLocation ( GLuint program, const char *name ) void glGetVertexAttribfv ( GLuint index, GLenum pname, GLfloat *params ) void glGetVertexAttribiv ( GLuint index, GLenum pname, GLint *params ) // void glGetVertexAttribPointerv ( GLuint index, GLenum pname, void **pointer )
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index ce98b67..69b9c34 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -77,6 +77,7 @@ EGLConfig config) : mFlinger(flinger), mType(type), mHwcDisplayId(-1), + mDisplayToken(displayToken), mNativeWindow(nativeWindow), mFramebufferSurface(framebufferSurface), mDisplay(EGL_NO_DISPLAY),
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index 2eb74b7..068fdcd 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -48,25 +48,15 @@ namespace android { -#define MIN_HWC_HEADER_VERSION 0 +#define MIN_HWC_HEADER_VERSION HWC_HEADER_VERSION static uint32_t hwcApiVersion(const hwc_composer_device_1_t* hwc) { uint32_t hwcVersion = hwc->common.version; - if (MIN_HWC_HEADER_VERSION == 0 && - (hwcVersion & HARDWARE_API_VERSION_2_MAJ_MIN_MASK) == 0) { - // legacy version encoding - hwcVersion <<= 16; - } return hwcVersion & HARDWARE_API_VERSION_2_MAJ_MIN_MASK; } static uint32_t hwcHeaderVersion(const hwc_composer_device_1_t* hwc) { uint32_t hwcVersion = hwc->common.version; - if (MIN_HWC_HEADER_VERSION == 0 && - (hwcVersion & HARDWARE_API_VERSION_2_MAJ_MIN_MASK) == 0) { - // legacy version encoding - hwcVersion <<= 16; - } return hwcVersion & HARDWARE_API_VERSION_2_HEADER_MASK; }
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 842471f..9afa4c1 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -191,12 +191,22 @@ return token; } +void SurfaceFlinger::createBuiltinDisplayLocked(DisplayDevice::DisplayType type) { + ALOGW_IF(mBuiltinDisplays[type], + "Overwriting display token for display type %d", type); + mBuiltinDisplays[type] = new BBinder(); + DisplayDeviceState info(type); + // All non-virtual displays are currently considered secure. + info.isSecure = true; + mCurrentState.displays.add(mBuiltinDisplays[type], info); +} + sp<IBinder> SurfaceFlinger::getBuiltInDisplay(int32_t id) { if (uint32_t(id) >= DisplayDevice::NUM_DISPLAY_TYPES) { ALOGE("getDefaultDisplay: id=%d is not a valid default display id", id); return NULL; } - return mDefaultDisplays[id]; + return mBuiltinDisplays[id]; } sp<IGraphicBufferAlloc> SurfaceFlinger::createGraphicBufferAlloc() @@ -462,6 +472,8 @@ ALOGI( "SurfaceFlinger's main thread ready to run. " "Initializing graphics H/W..."); + Mutex::Autolock _l(mStateLock); + // initialize EGL for the default display mEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(mEGLDisplay, NULL, NULL); @@ -482,14 +494,13 @@ // initialize our non-virtual displays for (size_t i=0 ; i<DisplayDevice::NUM_DISPLAY_TYPES ; i++) { DisplayDevice::DisplayType type((DisplayDevice::DisplayType)i); - mDefaultDisplays[i] = new BBinder(); - wp<IBinder> token = mDefaultDisplays[i]; - // set-up the displays that are already connected if (mHwc->isConnected(i) || type==DisplayDevice::DISPLAY_PRIMARY) { // All non-virtual displays are currently considered secure. bool isSecure = true; - mCurrentState.displays.add(token, DisplayDeviceState(type)); + createBuiltinDisplayLocked(type); + wp<IBinder> token = mBuiltinDisplays[i]; + sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i); sp<SurfaceTextureClient> stc = new SurfaceTextureClient( static_cast< sp<ISurfaceTexture> >(fbs->getBufferQueue())); @@ -601,9 +612,9 @@ } status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) { - int32_t type = BAD_VALUE; + int32_t type = NAME_NOT_FOUND; for (int i=0 ; i<DisplayDevice::NUM_DISPLAY_TYPES ; i++) { - if (display == mDefaultDisplays[i]) { + if (display == mBuiltinDisplays[i]) { type = i; break; } @@ -614,10 +625,6 @@ } const HWComposer& hwc(getHwComposer()); - if (!hwc.isConnected(type)) { - return NAME_NOT_FOUND; - } - float xdpi = hwc.getDpiX(type); float ydpi = hwc.getDpiY(type); @@ -745,11 +752,11 @@ if (uint32_t(type) < DisplayDevice::NUM_DISPLAY_TYPES) { Mutex::Autolock _l(mStateLock); - if (connected == false) { - mCurrentState.displays.removeItem(mDefaultDisplays[type]); + if (connected) { + createBuiltinDisplayLocked((DisplayDevice::DisplayType)type); } else { - DisplayDeviceState info((DisplayDevice::DisplayType)type); - mCurrentState.displays.add(mDefaultDisplays[type], info); + mCurrentState.displays.removeItem(mBuiltinDisplays[type]); + mBuiltinDisplays[type].clear(); } setTransactionFlags(eDisplayTransactionNeeded); @@ -1151,7 +1158,6 @@ for (size_t i=0 ; i<cc ; i++) { if (draw.indexOfKey(curr.keyAt(i)) < 0) { const DisplayDeviceState& state(curr[i]); - bool isSecure = false; sp<FramebufferSurface> fbs; sp<SurfaceTextureClient> stc; @@ -1162,10 +1168,6 @@ "surface is provided (%p), ignoring it", state.surface.get()); - // All non-virtual displays are currently considered - // secure. - isSecure = true; - // for supported (by hwc) displays we provide our // own rendering surface fbs = new FramebufferSurface(*mHwc, state.type); @@ -1176,13 +1178,12 @@ if (state.surface != NULL) { stc = new SurfaceTextureClient(state.surface); } - isSecure = state.isSecure; } const wp<IBinder>& display(curr.keyAt(i)); if (stc != NULL) { sp<DisplayDevice> hw = new DisplayDevice(this, - state.type, isSecure, display, stc, fbs, + state.type, state.isSecure, display, stc, fbs, mEGLConfig); hw->setLayerStack(state.layerStack); hw->setProjection(state.orientation, @@ -2045,7 +2046,7 @@ Vector<DisplayState> displays; DisplayState d; d.what = DisplayState::eDisplayProjectionChanged; - d.token = mDefaultDisplays[DisplayDevice::DISPLAY_PRIMARY]; + d.token = mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]; d.orientation = DisplayState::eOrientationDefault; d.frame.makeInvalid(); d.viewport.makeInvalid();
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index b0d3bac..1b549e4 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -112,7 +112,7 @@ // returns the default Display sp<const DisplayDevice> getDefaultDisplayDevice() const { - return getDisplayDevice(mDefaultDisplays[DisplayDevice::DISPLAY_PRIMARY]); + return getDisplayDevice(mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]); } // utility function to delete a texture on the main thread @@ -328,6 +328,9 @@ // called when starting, or restarting after system_server death void initializeDisplays(); + // Create an IBinder for a builtin display and add it to current state + void createBuiltinDisplayLocked(DisplayDevice::DisplayType type); + // NOTE: can only be called from the main thread or with mStateLock held sp<const DisplayDevice> getDisplayDevice(const wp<IBinder>& dpy) const { return mDisplays.valueFor(dpy); @@ -422,7 +425,7 @@ EGLContext mEGLContext; EGLConfig mEGLConfig; EGLDisplay mEGLDisplay; - sp<IBinder> mDefaultDisplays[DisplayDevice::NUM_DISPLAY_TYPES]; + sp<IBinder> mBuiltinDisplays[DisplayDevice::NUM_DISPLAY_TYPES]; // Can only accessed from the main thread, these members // don't need synchronization