diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/camera/CameraParameters.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/Caches.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/Caches.h | 3 | ||||
-rw-r--r-- | libs/hwui/DisplayListRenderer.cpp | 22 | ||||
-rw-r--r-- | libs/hwui/DisplayListRenderer.h | 6 | ||||
-rw-r--r-- | libs/hwui/Layer.h | 4 | ||||
-rw-r--r-- | libs/hwui/LayerCache.cpp | 16 | ||||
-rw-r--r-- | libs/hwui/LayerCache.h | 5 | ||||
-rw-r--r-- | libs/hwui/LayerRenderer.cpp | 10 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 8 | ||||
-rw-r--r-- | libs/hwui/Properties.h | 2 | ||||
-rw-r--r-- | libs/hwui/SkiaShader.cpp | 7 | ||||
-rw-r--r-- | libs/hwui/TextureCache.cpp | 2 | ||||
-rw-r--r-- | libs/rs/scriptc/rs_core.rsh | 20 | ||||
-rw-r--r-- | libs/rs/scriptc/rs_math.rsh | 21 | ||||
-rw-r--r-- | libs/ui/tests/Android.mk | 2 | ||||
-rw-r--r-- | libs/utils/tests/Android.mk | 3 | ||||
-rw-r--r-- | libs/utils/tests/ZipFileRO_test.cpp | 64 |
18 files changed, 167 insertions, 34 deletions
diff --git a/libs/camera/CameraParameters.cpp b/libs/camera/CameraParameters.cpp index 9392cf2..d8fef09 100644 --- a/libs/camera/CameraParameters.cpp +++ b/libs/camera/CameraParameters.cpp @@ -84,6 +84,8 @@ const char CameraParameters::KEY_VIDEO_FRAME_FORMAT[] = "video-frame-format"; const char CameraParameters::KEY_VIDEO_SIZE[] = "video-size"; const char CameraParameters::KEY_SUPPORTED_VIDEO_SIZES[] = "video-size-values"; const char CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO[] = "preferred-preview-size-for-video"; +const char CameraParameters::KEY_MAX_NUM_DETECTED_FACES_HW[] = "max-num-detected-faces-hw"; +const char CameraParameters::KEY_MAX_NUM_DETECTED_FACES_SW[] = "max-num-detected-faces-sw"; const char CameraParameters::TRUE[] = "true"; const char CameraParameters::FALSE[] = "false"; diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp index 7114b6a..c5858e9 100644 --- a/libs/hwui/Caches.cpp +++ b/libs/hwui/Caches.cpp @@ -173,13 +173,15 @@ void Caches::flush(FlushMode mode) { gradientCache.clear(); // fall through case kFlushMode_Moderate: - layerCache.clear(); pathCache.clear(); roundRectShapeCache.clear(); circleShapeCache.clear(); ovalShapeCache.clear(); rectShapeCache.clear(); arcShapeCache.clear(); + // fall through + case kFlushMode_Layers: + layerCache.clear(); break; } } diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h index 76dff4b..cdcbf21 100644 --- a/libs/hwui/Caches.h +++ b/libs/hwui/Caches.h @@ -101,7 +101,8 @@ class Caches: public Singleton<Caches> { public: enum FlushMode { - kFlushMode_Moderate = 0, + kFlushMode_Layers = 0, + kFlushMode_Moderate, kFlushMode_Full }; diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index 886c05c..88cfc5a 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -74,12 +74,17 @@ void DisplayList::outputLogBuffer(int fd) { if (logBuffer.isEmpty()) { return; } - String8 cachesLog; - Caches::getInstance().dumpMemoryUsage(cachesLog); + FILE *file = fdopen(fd, "a"); - fprintf(file, "\nCaches:\n%s", cachesLog.string()); + fprintf(file, "\nRecent DisplayList operations\n"); logBuffer.outputCommands(file, OP_NAMES); + + String8 cachesLog; + Caches::getInstance().dumpMemoryUsage(cachesLog); + fprintf(file, "\nCaches:\n%s", cachesLog.string()); + fprintf(file, "\n"); + fflush(file); } @@ -143,10 +148,10 @@ void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorde clearResources(); } - size_t size = writer.size(); - void* buffer = sk_malloc_throw(size); + mSize = writer.size(); + void* buffer = sk_malloc_throw(mSize); writer.flatten(buffer); - mReader.setMemory(buffer, size); + mReader.setMemory(buffer, mSize); Caches& caches = Caches::getInstance(); @@ -188,6 +193,11 @@ void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorde } void DisplayList::init() { + mSize = 0; +} + +size_t DisplayList::getSize() { + return mSize; } /** diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index 8157631..69e72a4 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -37,7 +37,7 @@ namespace uirenderer { // Defines /////////////////////////////////////////////////////////////////////////////// -#define MIN_WRITER_SIZE 16384 +#define MIN_WRITER_SIZE 4096 // Debug #if DEBUG_DISPLAY_LIST @@ -105,6 +105,8 @@ public: void initFromDisplayListRenderer(const DisplayListRenderer& recorder, bool reusing = false); + size_t getSize(); + bool replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level = 0); void output(OpenGLRenderer& renderer, uint32_t level = 0); @@ -203,6 +205,8 @@ private: Vector<SkiaShader*> mShaders; mutable SkFlattenableReadBuffer mReader; + + size_t mSize; }; /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index 0c536b0..dd75497 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -191,6 +191,10 @@ struct Layer { if (texture.id) glDeleteTextures(1, &texture.id); } + inline void deleteFbo() { + if (fbo) glDeleteFramebuffers(1, &fbo); + } + inline void allocateTexture(GLenum format, GLenum storage) { glTexImage2D(renderTarget, 0, format, getWidth(), getHeight(), 0, format, storage, NULL); } diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp index 36083af..0af0177 100644 --- a/libs/hwui/LayerCache.cpp +++ b/libs/hwui/LayerCache.cpp @@ -68,7 +68,9 @@ void LayerCache::setMaxSize(uint32_t maxSize) { void LayerCache::deleteLayer(Layer* layer) { if (layer) { + LAYER_LOGD("Destroying layer %dx%d", layer->getWidth(), layer->getHeight()); mSize -= layer->getWidth() * layer->getHeight() * 4; + layer->deleteFbo(); layer->deleteTexture(); delete layer; } @@ -111,17 +113,21 @@ Layer* LayerCache::get(const uint32_t width, const uint32_t height) { glPixelStorei(GL_UNPACK_ALIGNMENT, 4); #if DEBUG_LAYERS - 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); - } + dump(); #endif } return layer; } +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); + } +} + bool LayerCache::resize(Layer* layer, const uint32_t width, const uint32_t height) { // TODO: We should be smarter and see if we have a texture of the appropriate // size already in the cache, and reuse it instead of creating a new one diff --git a/libs/hwui/LayerCache.h b/libs/hwui/LayerCache.h index 81b8bf3..a0eae59 100644 --- a/libs/hwui/LayerCache.h +++ b/libs/hwui/LayerCache.h @@ -101,6 +101,11 @@ public: */ uint32_t getSize(); + /** + * Prints out the content of the cache. + */ + void dump(); + private: void deleteLayer(Layer* layer); diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp index 1fa343b..7e8c7fd 100644 --- a/libs/hwui/LayerRenderer.cpp +++ b/libs/hwui/LayerRenderer.cpp @@ -167,7 +167,7 @@ void LayerRenderer::generateMesh() { /////////////////////////////////////////////////////////////////////////////// Layer* LayerRenderer::createLayer(uint32_t width, uint32_t height, bool isOpaque) { - LAYER_RENDERER_LOGD("Creating new layer %dx%d", width, height); + LAYER_RENDERER_LOGD("Requesting new render layer %dx%d", width, height); GLuint fbo = Caches::getInstance().fboCache.get(); if (!fbo) { @@ -288,16 +288,22 @@ void LayerRenderer::updateTextureLayer(Layer* layer, uint32_t width, uint32_t he void LayerRenderer::destroyLayer(Layer* layer) { if (layer) { - LAYER_RENDERER_LOGD("Destroying layer, fbo = %d", layer->getFbo()); + LAYER_RENDERER_LOGD("Recycling layer, %dx%d fbo = %d", + layer->getWidth(), layer->getHeight(), layer->getFbo()); if (layer->getFbo()) { Caches::getInstance().fboCache.put(layer->getFbo()); } if (!Caches::getInstance().layerCache.put(layer)) { + LAYER_RENDERER_LOGD(" Destroyed!"); layer->deleteTexture(); delete layer; } else { + LAYER_RENDERER_LOGD(" Cached!"); +#if DEBUG_LAYER_RENDERER + Caches::getInstance().layerCache.dump(); +#endif layer->region.clear(); } } diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index e67abbd..ed2fa3c 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -1489,13 +1489,19 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap, const float x = (int) floorf(dstLeft + mSnapshot->transform->getTranslateX() + 0.5f); const float y = (int) floorf(dstTop + mSnapshot->transform->getTranslateY() + 0.5f); - texture->setFilter(GL_NEAREST, GL_NEAREST, true); + GLenum filter = GL_NEAREST; + if (u1 > 0.0f || u2 < 1.0f || v1 > 0.0f || v2 < 1.0f) { + filter = GL_LINEAR; + } + texture->setFilter(filter, filter, true); + drawTextureMesh(x, y, x + (dstRight - dstLeft), y + (dstBottom - dstTop), texture->id, alpha / 255.0f, mode, texture->blend, &mMeshVertices[0].position[0], &mMeshVertices[0].texture[0], GL_TRIANGLE_STRIP, gMeshCount, false, true); } else { texture->setFilter(GL_LINEAR, GL_LINEAR, true); + drawTextureMesh(dstLeft, dstTop, dstRight, dstBottom, texture->id, alpha / 255.0f, mode, texture->blend, &mMeshVertices[0].position[0], &mMeshVertices[0].texture[0], GL_TRIANGLE_STRIP, gMeshCount); diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h index 47049e2..923978f 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -68,7 +68,7 @@ enum DebugLevel { #define MB(s) s * 1024 * 1024 #define DEFAULT_TEXTURE_CACHE_SIZE 24.0f -#define DEFAULT_LAYER_CACHE_SIZE 24.0f +#define DEFAULT_LAYER_CACHE_SIZE 16.0f #define DEFAULT_PATH_CACHE_SIZE 4.0f #define DEFAULT_SHAPE_CACHE_SIZE 1.0f #define DEFAULT_PATCH_CACHE_SIZE 512 diff --git a/libs/hwui/SkiaShader.cpp b/libs/hwui/SkiaShader.cpp index 1a60dca..06382f2 100644 --- a/libs/hwui/SkiaShader.cpp +++ b/libs/hwui/SkiaShader.cpp @@ -144,8 +144,11 @@ void SkiaBitmapShader::setupProgram(Program* program, const mat4& modelView, // Uniforms bindTexture(texture, mWrapS, mWrapT); - GLenum filter = textureTransform.isPureTranslate() ? GL_NEAREST : GL_LINEAR; - texture->setFilter(filter, filter); + // Assume linear here; we should really check the transform in + // ::updateTransforms() but we don't have the texture object + // available at that point. The optimization is not worth the + // effort for now. + texture->setFilter(GL_LINEAR, GL_LINEAR); glUniform1i(program->getUniform("bitmapSampler"), textureSlot); glUniformMatrix4fv(program->getUniform("textureTransform"), 1, diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp index f926fdd..fbdbf92 100644 --- a/libs/hwui/TextureCache.cpp +++ b/libs/hwui/TextureCache.cpp @@ -165,7 +165,7 @@ void TextureCache::clearGarbage() { void TextureCache::clear() { mCache.clear(); - TEXTURE_LOGD("TextureCache:clear(), miSize = %d", mSize); + TEXTURE_LOGD("TextureCache:clear(), mSize = %d", mSize); } void TextureCache::generateTexture(SkBitmap* bitmap, Texture* texture, bool regenerate) { diff --git a/libs/rs/scriptc/rs_core.rsh b/libs/rs/scriptc/rs_core.rsh index 4768bbe..d939fb3 100644 --- a/libs/rs/scriptc/rs_core.rsh +++ b/libs/rs/scriptc/rs_core.rsh @@ -269,6 +269,7 @@ rsMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right, float bottom, floa extern void __attribute__((overloadable)) rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far); +#if !defined(RS_VERSION) || (RS_VERSION < 14) _RS_RUNTIME float4 __attribute__((overloadable)) rsMatrixMultiply(rs_matrix4x4 *m, float4 in); @@ -286,6 +287,25 @@ rsMatrixMultiply(rs_matrix3x3 *m, float2 in); _RS_RUNTIME float2 __attribute__((overloadable)) rsMatrixMultiply(rs_matrix2x2 *m, float2 in); +#else +_RS_RUNTIME float4 __attribute__((overloadable)) +rsMatrixMultiply(const rs_matrix4x4 *m, float4 in); + +_RS_RUNTIME float4 __attribute__((overloadable)) +rsMatrixMultiply(const rs_matrix4x4 *m, float3 in); + +_RS_RUNTIME float4 __attribute__((overloadable)) +rsMatrixMultiply(const rs_matrix4x4 *m, float2 in); + +_RS_RUNTIME float3 __attribute__((overloadable)) +rsMatrixMultiply(const rs_matrix3x3 *m, float3 in); + +_RS_RUNTIME float3 __attribute__((overloadable)) +rsMatrixMultiply(const rs_matrix3x3 *m, float2 in); + +_RS_RUNTIME float2 __attribute__((overloadable)) +rsMatrixMultiply(const rs_matrix2x2 *m, float2 in); +#endif // Returns true if the matrix was successfully inversed extern bool __attribute__((overloadable)) rsMatrixInverse(rs_matrix4x4 *m); diff --git a/libs/rs/scriptc/rs_math.rsh b/libs/rs/scriptc/rs_math.rsh index fb5c4f6..1d36cc6 100644 --- a/libs/rs/scriptc/rs_math.rsh +++ b/libs/rs/scriptc/rs_math.rsh @@ -249,7 +249,16 @@ typedef struct rs_script_call { uint32_t arrayEnd; } rs_script_call_t; -#if 1//(RS_VERSION >= 14) +#if !defined(RS_VERSION) || (RS_VERSION < 14) +extern void __attribute__((overloadable)) + rsForEach(rs_script script, rs_allocation input, + rs_allocation output, const void * usrData, + const rs_script_call_t *); + +extern void __attribute__((overloadable)) + rsForEach(rs_script script, rs_allocation input, + rs_allocation output, const void * usrData); +#else extern void __attribute__((overloadable)) rsForEach(rs_script script, rs_allocation input, rs_allocation output); @@ -260,18 +269,8 @@ extern void __attribute__((overloadable)) extern void __attribute__((overloadable)) rsForEach(rs_script script, rs_allocation input, rs_allocation output, const void * usrData, size_t usrDataLen, const rs_script_call_t *); -#else -extern void __attribute__((overloadable)) - rsForEach(rs_script script, rs_allocation input, - rs_allocation output, const void * usrData, - const rs_script_call_t *); #endif -// Move me once dependant changes are in. -extern void __attribute__((overloadable)) - rsForEach(rs_script script, rs_allocation input, - rs_allocation output, const void * usrData); - /** * Atomic add one to the value at addr. diff --git a/libs/ui/tests/Android.mk b/libs/ui/tests/Android.mk index 693a32a..700b604 100644 --- a/libs/ui/tests/Android.mk +++ b/libs/ui/tests/Android.mk @@ -45,4 +45,4 @@ $(foreach file,$(test_src_files), \ ) # Build the manual test programs. -include $(call all-subdir-makefiles) +include $(call all-makefiles-under, $(LOCAL_PATH)) diff --git a/libs/utils/tests/Android.mk b/libs/utils/tests/Android.mk index 8726a53..b97f52f 100644 --- a/libs/utils/tests/Android.mk +++ b/libs/utils/tests/Android.mk @@ -8,7 +8,8 @@ test_src_files := \ ObbFile_test.cpp \ Looper_test.cpp \ String8_test.cpp \ - Unicode_test.cpp + Unicode_test.cpp \ + ZipFileRO_test.cpp \ shared_libraries := \ libz \ diff --git a/libs/utils/tests/ZipFileRO_test.cpp b/libs/utils/tests/ZipFileRO_test.cpp new file mode 100644 index 0000000..7a1d0bd --- /dev/null +++ b/libs/utils/tests/ZipFileRO_test.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2011 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. + */ + +#define LOG_TAG "ZipFileRO_test" +#include <utils/Log.h> +#include <utils/ZipFileRO.h> + +#include <gtest/gtest.h> + +#include <fcntl.h> +#include <string.h> + +namespace android { + +class ZipFileROTest : public testing::Test { +protected: + virtual void SetUp() { + } + + virtual void TearDown() { + } +}; + +TEST_F(ZipFileROTest, ZipTimeConvertSuccess) { + struct tm t; + + // 2011-06-29 14:40:40 + long when = 0x3EDD7514; + + ZipFileRO::zipTimeToTimespec(when, &t); + + EXPECT_EQ(2011, t.tm_year + 1900) + << "Year was improperly converted."; + + EXPECT_EQ(6, t.tm_mon) + << "Month was improperly converted."; + + EXPECT_EQ(29, t.tm_mday) + << "Day was improperly converted."; + + EXPECT_EQ(14, t.tm_hour) + << "Hour was improperly converted."; + + EXPECT_EQ(40, t.tm_min) + << "Minute was improperly converted."; + + EXPECT_EQ(40, t.tm_sec) + << "Second was improperly converted."; +} + +} |