diff options
-rw-r--r-- | build/phone-hdpi-512-dalvik-heap.mk | 5 | ||||
-rw-r--r-- | build/phone-hdpi-dalvik-heap.mk | 5 | ||||
-rw-r--r-- | build/phone-xhdpi-1024-dalvik-heap.mk | 5 | ||||
-rw-r--r-- | build/tablet-10in-xhdpi-2048-dalvik-heap.mk | 5 | ||||
-rw-r--r-- | build/tablet-7in-hdpi-1024-dalvik-heap.mk | 6 | ||||
-rw-r--r-- | build/tablet-dalvik-heap.mk | 5 | ||||
-rw-r--r-- | include/binder/MemoryHeapBase.h | 5 | ||||
-rw-r--r-- | include/gui/GuiConfig.h | 29 | ||||
-rw-r--r-- | include/ui/UiConfig.h | 29 | ||||
-rw-r--r-- | libs/gui/Android.mk | 3 | ||||
-rw-r--r-- | libs/gui/GuiConfig.cpp | 38 | ||||
-rw-r--r-- | libs/ui/Android.mk | 3 | ||||
-rw-r--r-- | libs/ui/UiConfig.cpp | 36 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 154 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 5 |
15 files changed, 298 insertions, 35 deletions
diff --git a/build/phone-hdpi-512-dalvik-heap.mk b/build/phone-hdpi-512-dalvik-heap.mk index 16e0505..102c3f1 100644 --- a/build/phone-hdpi-512-dalvik-heap.mk +++ b/build/phone-hdpi-512-dalvik-heap.mk @@ -20,4 +20,7 @@ PRODUCT_PROPERTY_OVERRIDES += \ dalvik.vm.heapstartsize=5m \ dalvik.vm.heapgrowthlimit=48m \ - dalvik.vm.heapsize=128m + dalvik.vm.heapsize=128m \ + dalvik.vm.heaptargetutilization=0.75 \ + dalvik.vm.heapminfree=512k \ + dalvik.vm.heapmaxfree=2m diff --git a/build/phone-hdpi-dalvik-heap.mk b/build/phone-hdpi-dalvik-heap.mk index ab33b96..cc0ac90 100644 --- a/build/phone-hdpi-dalvik-heap.mk +++ b/build/phone-hdpi-dalvik-heap.mk @@ -18,4 +18,7 @@ PRODUCT_PROPERTY_OVERRIDES += \ dalvik.vm.heapstartsize=5m \ - dalvik.vm.heapsize=32m + dalvik.vm.heapsize=32m \ + dalvik.vm.heaptargetutilization=0.75 \ + dalvik.vm.heapminfree=512k \ + dalvik.vm.heapmaxfree=2m diff --git a/build/phone-xhdpi-1024-dalvik-heap.mk b/build/phone-xhdpi-1024-dalvik-heap.mk index f76535a..0e850e8 100644 --- a/build/phone-xhdpi-1024-dalvik-heap.mk +++ b/build/phone-xhdpi-1024-dalvik-heap.mk @@ -19,4 +19,7 @@ PRODUCT_PROPERTY_OVERRIDES += \ dalvik.vm.heapstartsize=8m \ dalvik.vm.heapgrowthlimit=64m \ - dalvik.vm.heapsize=256m + dalvik.vm.heapsize=256m \ + dalvik.vm.heaptargetutilization=0.75 \ + dalvik.vm.heapminfree=512k \ + dalvik.vm.heapmaxfree=8m diff --git a/build/tablet-10in-xhdpi-2048-dalvik-heap.mk b/build/tablet-10in-xhdpi-2048-dalvik-heap.mk index eeec219..b4d9cea 100644 --- a/build/tablet-10in-xhdpi-2048-dalvik-heap.mk +++ b/build/tablet-10in-xhdpi-2048-dalvik-heap.mk @@ -19,4 +19,7 @@ PRODUCT_PROPERTY_OVERRIDES += \ dalvik.vm.heapstartsize=16m \ dalvik.vm.heapgrowthlimit=192m \ - dalvik.vm.heapsize=768m + dalvik.vm.heapsize=768m \ + dalvik.vm.heaptargetutilization=0.75 \ + dalvik.vm.heapminfree=512k \ + dalvik.vm.heapmaxfree=8m diff --git a/build/tablet-7in-hdpi-1024-dalvik-heap.mk b/build/tablet-7in-hdpi-1024-dalvik-heap.mk index 63aede6..5bbd2b0 100644 --- a/build/tablet-7in-hdpi-1024-dalvik-heap.mk +++ b/build/tablet-7in-hdpi-1024-dalvik-heap.mk @@ -19,5 +19,7 @@ PRODUCT_PROPERTY_OVERRIDES += \ dalvik.vm.heapstartsize=8m \ dalvik.vm.heapgrowthlimit=64m \ - dalvik.vm.heapsize=384m -
\ No newline at end of file + dalvik.vm.heapsize=384m \ + dalvik.vm.heaptargetutilization=0.75 \ + dalvik.vm.heapminfree=512k \ + dalvik.vm.heapmaxfree=8m diff --git a/build/tablet-dalvik-heap.mk b/build/tablet-dalvik-heap.mk index 826a380..f577fb8 100644 --- a/build/tablet-dalvik-heap.mk +++ b/build/tablet-dalvik-heap.mk @@ -19,4 +19,7 @@ PRODUCT_PROPERTY_OVERRIDES += \ dalvik.vm.heapstartsize=5m \ dalvik.vm.heapgrowthlimit=48m \ - dalvik.vm.heapsize=256m + dalvik.vm.heapsize=256m \ + dalvik.vm.heaptargetutilization=0.75 \ + dalvik.vm.heapminfree=512k \ + dalvik.vm.heapmaxfree=2m diff --git a/include/binder/MemoryHeapBase.h b/include/binder/MemoryHeapBase.h index bbbda9c..ea9b66c 100644 --- a/include/binder/MemoryHeapBase.h +++ b/include/binder/MemoryHeapBase.h @@ -58,10 +58,13 @@ public: /* implement IMemoryHeap interface */ virtual int getHeapID() const; + + /* virtual address of the heap. returns MAP_FAILED in case of error */ virtual void* getBase() const; + virtual size_t getSize() const; virtual uint32_t getFlags() const; - virtual uint32_t getOffset() const; + virtual uint32_t getOffset() const; const char* getDevice() const; diff --git a/include/gui/GuiConfig.h b/include/gui/GuiConfig.h new file mode 100644 index 0000000..b020ed9 --- /dev/null +++ b/include/gui/GuiConfig.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 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. + */ + +#ifndef ANDROID_GUI_CONFIG_H +#define ANDROID_GUI_CONFIG_H + +#include <utils/String8.h> + +namespace android { + +// Append the libgui configuration details to configStr. +void appendGuiConfigString(String8& configStr); + +}; // namespace android + +#endif /*ANDROID_GUI_CONFIG_H*/ diff --git a/include/ui/UiConfig.h b/include/ui/UiConfig.h new file mode 100644 index 0000000..fcf8ed5 --- /dev/null +++ b/include/ui/UiConfig.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 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. + */ + +#ifndef ANDROID_UI_CONFIG_H +#define ANDROID_UI_CONFIG_H + +#include <utils/String8.h> + +namespace android { + +// Append the libui configuration details to configStr. +void appendUiConfigString(String8& configStr); + +}; // namespace android + +#endif /*ANDROID_UI_CONFIG_H*/ diff --git a/libs/gui/Android.mk b/libs/gui/Android.mk index 282c25a..923845c 100644 --- a/libs/gui/Android.mk +++ b/libs/gui/Android.mk @@ -24,7 +24,8 @@ LOCAL_SRC_FILES:= \ SurfaceComposerClient.cpp \ DummyConsumer.cpp \ CpuConsumer.cpp \ - BufferItemConsumer.cpp + BufferItemConsumer.cpp \ + GuiConfig.cpp LOCAL_SHARED_LIBRARIES := \ libbinder \ diff --git a/libs/gui/GuiConfig.cpp b/libs/gui/GuiConfig.cpp new file mode 100644 index 0000000..0744e4f --- /dev/null +++ b/libs/gui/GuiConfig.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 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. + */ + +#include <gui/GuiConfig.h> + +namespace android { + +void appendGuiConfigString(String8& configStr) +{ + static const char* config = + " [libgui" +#ifdef USE_FENCE_SYNC + " USE_FENCE_SYNC" +#endif +#ifdef USE_NATIVE_FENCE_SYNC + " USE_NATIVE_FENCE_SYNC" +#endif +#ifdef ALLOW_DEQUEUE_CURRENT_BUFFER + " ALLOW_DEQUEUE_CURRENT_BUFFER" +#endif + "]"; + configStr.append(config); +} + +}; // namespace android diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk index 80c28a1..0d2e44c 100644 --- a/libs/ui/Android.mk +++ b/libs/ui/Android.mk @@ -23,7 +23,8 @@ LOCAL_SRC_FILES:= \ GraphicBufferMapper.cpp \ PixelFormat.cpp \ Rect.cpp \ - Region.cpp + Region.cpp \ + UiConfig.cpp LOCAL_SHARED_LIBRARIES := \ libcutils \ diff --git a/libs/ui/UiConfig.cpp b/libs/ui/UiConfig.cpp new file mode 100644 index 0000000..8b2130e --- /dev/null +++ b/libs/ui/UiConfig.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 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. + */ + +#include <ui/UiConfig.h> + +namespace android { + +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + +void appendUiConfigString(String8& configStr) +{ + static const char* config = + " [libui" +#ifdef FRAMEBUFFER_FORCE_FORMAT + " FRAMEBUFFER_FORCE_FORMAT=" TOSTRING(FRAMEBUFFER_FORCE_FORMAT) +#endif + "]"; + configStr.append(config); +} + + +}; // namespace android diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index bc7552d..b3650bd 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -37,11 +37,13 @@ #include <gui/BitTube.h> #include <gui/BufferQueue.h> +#include <gui/GuiConfig.h> #include <gui/IDisplayEventConnection.h> #include <gui/SurfaceTextureClient.h> #include <ui/GraphicBufferAllocator.h> #include <ui/PixelFormat.h> +#include <ui/UiConfig.h> #include <utils/misc.h> #include <utils/String8.h> @@ -235,10 +237,10 @@ void SurfaceFlinger::deleteTextureAsync(GLuint texture) { postMessageAsync(new MessageDestroyGLTexture(texture)); } -status_t SurfaceFlinger::selectConfigForPixelFormat( +status_t SurfaceFlinger::selectConfigForAttribute( EGLDisplay dpy, EGLint const* attrs, - PixelFormat format, + EGLint attribute, EGLint wanted, EGLConfig* outConfig) { EGLConfig config = NULL; @@ -247,11 +249,20 @@ status_t SurfaceFlinger::selectConfigForPixelFormat( EGLConfig* const configs = new EGLConfig[numConfigs]; eglChooseConfig(dpy, attrs, configs, numConfigs, &n); - for (int i=0 ; i<n ; i++) { - EGLint nativeVisualId = 0; - eglGetConfigAttrib(dpy, configs[i], EGL_NATIVE_VISUAL_ID, &nativeVisualId); - if (nativeVisualId>0 && format == nativeVisualId) { - *outConfig = configs[i]; + if (n) { + if (attribute != EGL_NONE) { + for (int i=0 ; i<n ; i++) { + EGLint value = 0; + eglGetConfigAttrib(dpy, configs[i], attribute, &value); + if (wanted == value) { + *outConfig = configs[i]; + delete [] configs; + return NO_ERROR; + } + } + } else { + // just pick the first one + *outConfig = configs[0]; delete [] configs; return NO_ERROR; } @@ -260,6 +271,58 @@ status_t SurfaceFlinger::selectConfigForPixelFormat( return NAME_NOT_FOUND; } +class EGLAttributeVector { + struct Attribute; + class Adder; + friend class Adder; + KeyedVector<Attribute, EGLint> mList; + struct Attribute { + Attribute() {}; + Attribute(EGLint v) : v(v) { } + EGLint v; + bool operator < (const Attribute& other) const { + // this places EGL_NONE at the end + EGLint lhs(v); + EGLint rhs(other.v); + if (lhs == EGL_NONE) lhs = 0x7FFFFFFF; + if (rhs == EGL_NONE) rhs = 0x7FFFFFFF; + return lhs < rhs; + } + }; + class Adder { + friend class EGLAttributeVector; + EGLAttributeVector& v; + EGLint attribute; + Adder(EGLAttributeVector& v, EGLint attribute) + : v(v), attribute(attribute) { + } + public: + void operator = (EGLint value) { + if (attribute != EGL_NONE) { + v.mList.add(attribute, value); + } + } + operator EGLint () const { return v.mList[attribute]; } + }; +public: + EGLAttributeVector() { + mList.add(EGL_NONE, EGL_NONE); + } + void remove(EGLint attribute) { + if (attribute != EGL_NONE) { + mList.removeItem(attribute); + } + } + Adder operator [] (EGLint attribute) { + return Adder(*this, attribute); + } + EGLint operator [] (EGLint attribute) const { + return mList[attribute]; + } + // cast-operator to (EGLint const*) + operator EGLint const* () const { return &mList.keyAt(0).v; } +}; + EGLConfig SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisualId) { // select our EGLConfig. It must support EGL_RECORDABLE_ANDROID if // it is to be used with WIFI displays @@ -267,32 +330,42 @@ EGLConfig SurfaceFlinger::selectEGLConfig(EGLDisplay display, EGLint nativeVisua EGLint dummy; status_t err; - EGLint attribs[] = { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - // The rest of the attributes must be in this order and at the end - // of the list; we rely on that for fallback searches below. - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_RECORDABLE_ANDROID, EGL_TRUE, - EGL_NONE - }; - err = selectConfigForPixelFormat(display, attribs, nativeVisualId, &config); + EGLAttributeVector attribs; + attribs[EGL_SURFACE_TYPE] = EGL_WINDOW_BIT; + attribs[EGL_RECORDABLE_ANDROID] = EGL_TRUE; + attribs[EGL_FRAMEBUFFER_TARGET_ANDROID] = EGL_TRUE; + attribs[EGL_RED_SIZE] = 8; + attribs[EGL_GREEN_SIZE] = 8; + attribs[EGL_BLUE_SIZE] = 8; + + err = selectConfigForAttribute(display, attribs, EGL_NONE, EGL_NONE, &config); + if (!err) + goto success; + + // maybe we failed because of EGL_FRAMEBUFFER_TARGET_ANDROID + ALOGW("no suitable EGLConfig found, trying without EGL_FRAMEBUFFER_TARGET_ANDROID"); + attribs.remove(EGL_FRAMEBUFFER_TARGET_ANDROID); + err = selectConfigForAttribute(display, attribs, + EGL_NATIVE_VISUAL_ID, nativeVisualId, &config); if (!err) goto success; // maybe we failed because of EGL_RECORDABLE_ANDROID ALOGW("no suitable EGLConfig found, trying without EGL_RECORDABLE_ANDROID"); - attribs[NELEM(attribs) - 3] = EGL_NONE; - err = selectConfigForPixelFormat(display, attribs, nativeVisualId, &config); + attribs.remove(EGL_RECORDABLE_ANDROID); + err = selectConfigForAttribute(display, attribs, + EGL_NATIVE_VISUAL_ID, nativeVisualId, &config); if (!err) goto success; // allow less than 24-bit color; the non-gpu-accelerated emulator only // supports 16-bit color ALOGW("no suitable EGLConfig found, trying with 16-bit color allowed"); - attribs[NELEM(attribs) - 9] = EGL_NONE; - err = selectConfigForPixelFormat(display, attribs, nativeVisualId, &config); + attribs.remove(EGL_RED_SIZE); + attribs.remove(EGL_GREEN_SIZE); + attribs.remove(EGL_BLUE_SIZE); + err = selectConfigForAttribute(display, attribs, + EGL_NATIVE_VISUAL_ID, nativeVisualId, &config); if (!err) goto success; @@ -790,6 +863,12 @@ void SurfaceFlinger::doDebugFlashRegions() if (mDebugRegion > 1) { usleep(mDebugRegion * 1000); } + + HWComposer& hwc(getHwComposer()); + if (hwc.initCheck() == NO_ERROR) { + status_t err = hwc.prepare(); + ALOGE_IF(err, "HWComposer::prepare failed (%s)", strerror(-err)); + } } void SurfaceFlinger::preComposition() @@ -2045,6 +2124,26 @@ void SurfaceFlinger::clearStatsLocked(const Vector<String16>& args, size_t& inde } } +/*static*/ void SurfaceFlinger::appendSfConfigString(String8& result) +{ + static const char* config = + " [sf" +#ifdef NO_RGBX_8888 + " NO_RGBX_8888" +#endif +#ifdef HAS_CONTEXT_PRIORITY + " HAS_CONTEXT_PRIORITY" +#endif +#ifdef NEVER_DEFAULT_TO_ASYNC_MODE + " NEVER_DEFAULT_TO_ASYNC_MODE" +#endif +#ifdef TARGET_DISABLE_TRIPLE_BUFFERING + " TARGET_DISABLE_TRIPLE_BUFFERING" +#endif + "]"; + result.append(config); +} + void SurfaceFlinger::dumpAllLocked( String8& result, char* buffer, size_t SIZE) const { @@ -2056,6 +2155,15 @@ void SurfaceFlinger::dumpAllLocked( nsecs_t inTransactionDuration = (inTransaction) ? now-inTransaction : 0; /* + * Dump library configuration. + */ + result.append("Build configuration:"); + appendSfConfigString(result); + appendUiConfigString(result); + appendGuiConfigString(result); + result.append("\n"); + + /* * Dump the visible layer list */ const LayerVector& currentLayers = mCurrentState.layersSortedByZ; @@ -2460,7 +2568,7 @@ status_t SurfaceFlinger::captureScreenImplLocked(const sp<IBinder>& display, sp<MemoryHeapBase> base( new MemoryHeapBase(size, 0, "screen-capture") ); void* const ptr = base->getBase(); - if (ptr) { + if (ptr != MAP_FAILED) { // capture the screen with glReadPixels() ScopedTrace _t(ATRACE_TAG, "glReadPixels"); glReadPixels(0, 0, sw, sh, GL_RGBA, GL_UNSIGNED_BYTE, ptr); diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index c9877b2..e5b939d 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -309,8 +309,8 @@ private: /* ------------------------------------------------------------------------ * EGL */ - static status_t selectConfigForPixelFormat(EGLDisplay dpy, - EGLint const* attrs, PixelFormat format, EGLConfig* outConfig); + static status_t selectConfigForAttribute(EGLDisplay dpy, + EGLint const* attrs, EGLint attribute, EGLint value, EGLConfig* outConfig); static EGLConfig selectEGLConfig(EGLDisplay disp, EGLint visualId); static EGLContext createGLContext(EGLDisplay disp, EGLConfig config); void initializeGL(EGLDisplay display); @@ -382,6 +382,7 @@ private: String8& result, char* buffer, size_t SIZE) const; void dumpAllLocked(String8& result, char* buffer, size_t SIZE) const; bool startDdmConnection(); + static void appendSfConfigString(String8& result); /* ------------------------------------------------------------------------ * Attributes |