diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/androidfw/ResourceTypes.cpp | 12 | ||||
-rw-r--r-- | libs/androidfw/tests/Android.mk | 31 | ||||
-rw-r--r-- | libs/androidfw/tests/InputEvent_test.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/FontRenderer.cpp | 49 | ||||
-rw-r--r-- | libs/hwui/FontRenderer.h | 7 |
5 files changed, 56 insertions, 45 deletions
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index 0107da4..fc2cd9e 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -506,10 +506,6 @@ status_t ResStringPool::getError() const void ResStringPool::uninit() { mError = NO_INIT; - if (mOwnedData) { - free(mOwnedData); - mOwnedData = NULL; - } if (mHeader != NULL && mCache != NULL) { for (size_t x = 0; x < mHeader->stringCount; x++) { if (mCache[x] != NULL) { @@ -520,6 +516,10 @@ void ResStringPool::uninit() free(mCache); mCache = NULL; } + if (mOwnedData) { + free(mOwnedData); + mOwnedData = NULL; + } } /** @@ -1209,6 +1209,10 @@ status_t ResXMLTree::setTo(const void* data, size_t size, bool copyData) uninit(); mEventCode = START_DOCUMENT; + if (!data || !size) { + return (mError=BAD_TYPE); + } + if (copyData) { mOwnedData = malloc(size); if (mOwnedData == NULL) { diff --git a/libs/androidfw/tests/Android.mk b/libs/androidfw/tests/Android.mk index 39009b8..4ae23ec 100644 --- a/libs/androidfw/tests/Android.mk +++ b/libs/androidfw/tests/Android.mk @@ -10,36 +10,25 @@ test_src_files := \ ObbFile_test.cpp shared_libraries := \ - libandroidfw \ - libcutils \ - libutils \ - libbinder \ - libui \ - libstlport \ - libskia + libandroidfw \ + libcutils \ + libutils \ + libbinder \ + libui \ + libstlport \ + libskia static_libraries := \ - libgtest \ - libgtest_main - -c_includes := \ - bionic \ - bionic/libstdc++/include \ - external/gtest/include \ - external/stlport/stlport \ - external/skia/include/core - -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)) \ ) # Build the manual test programs. diff --git a/libs/androidfw/tests/InputEvent_test.cpp b/libs/androidfw/tests/InputEvent_test.cpp index ac5549c..e9164d1 100644 --- a/libs/androidfw/tests/InputEvent_test.cpp +++ b/libs/androidfw/tests/InputEvent_test.cpp @@ -19,7 +19,7 @@ #include <binder/Parcel.h> #include <math.h> -#include <SkMatrix.h> +#include <core/SkMatrix.h> namespace android { diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index 4e97c88..47784a4 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -45,10 +45,10 @@ FontRenderer::FontRenderer() { mInitialized = false; mMaxNumberOfQuads = 1024; mCurrentQuadIndex = 0; + mLastQuadIndex = 0; mTextMesh = NULL; mCurrentCacheTexture = NULL; - mLastCacheTexture = NULL; mLinearFiltering = false; @@ -116,7 +116,6 @@ FontRenderer::~FontRenderer() { void FontRenderer::flushAllAndInvalidate() { if (mCurrentQuadIndex != 0) { issueDrawCommand(); - mCurrentQuadIndex = 0; } for (uint32_t i = 0; i < mActiveFonts.size(); i++) { @@ -320,8 +319,17 @@ void FontRenderer::checkInit() { mInitialized = true; } +void FontRenderer::updateDrawParams() { + if (mCurrentQuadIndex != mLastQuadIndex) { + mDrawOffsets.add((uint16_t*)(mLastQuadIndex * sizeof(uint16_t) * 6)); + mDrawCounts.add(mCurrentQuadIndex - mLastQuadIndex); + mDrawCacheTextures.add(mCurrentCacheTexture); + mLastQuadIndex = mCurrentQuadIndex; + } +} + void FontRenderer::checkTextureUpdate() { - if (!mUploadTexture && mLastCacheTexture == mCurrentCacheTexture) { + if (!mUploadTexture) { return; } @@ -355,16 +363,11 @@ void FontRenderer::checkTextureUpdate() { } } - caches.activeTexture(0); - glBindTexture(GL_TEXTURE_2D, mCurrentCacheTexture->getTextureId()); - - mCurrentCacheTexture->setLinearFiltering(mLinearFiltering, false); - mLastCacheTexture = mCurrentCacheTexture; - mUploadTexture = false; } void FontRenderer::issueDrawCommand() { + updateDrawParams(); checkTextureUpdate(); Caches& caches = Caches::getInstance(); @@ -378,20 +381,33 @@ void FontRenderer::issueDrawCommand() { caches.bindTexCoordsVertexPointer(force, buffer + offset); } - glDrawElements(GL_TRIANGLES, mCurrentQuadIndex * 6, GL_UNSIGNED_SHORT, NULL); + for (uint32_t i = 0; i < mDrawOffsets.size(); i++) { + uint16_t* offset = mDrawOffsets[i]; + uint32_t count = mDrawCounts[i]; + CacheTexture* texture = mDrawCacheTextures[i]; + + caches.activeTexture(0); + glBindTexture(GL_TEXTURE_2D, texture->getTextureId()); + + texture->setLinearFiltering(mLinearFiltering, false); + + glDrawElements(GL_TRIANGLES, count * 6, GL_UNSIGNED_SHORT, offset); + } mDrawn = true; + + mCurrentQuadIndex = 0; + mLastQuadIndex = 0; + mDrawOffsets.clear(); + mDrawCounts.clear(); + mDrawCacheTextures.clear(); } void FontRenderer::appendMeshQuadNoClip(float x1, float y1, float u1, float v1, float x2, float y2, float u2, float v2, float x3, float y3, float u3, float v3, float x4, float y4, float u4, float v4, CacheTexture* texture) { if (texture != mCurrentCacheTexture) { - if (mCurrentQuadIndex != 0) { - // First, draw everything stored already which uses the previous texture - issueDrawCommand(); - mCurrentQuadIndex = 0; - } + updateDrawParams(); // Now use the new texture id mCurrentCacheTexture = texture; } @@ -443,7 +459,6 @@ void FontRenderer::appendMeshQuad(float x1, float y1, float u1, float v1, if (mCurrentQuadIndex == mMaxNumberOfQuads) { issueDrawCommand(); - mCurrentQuadIndex = 0; } } @@ -462,7 +477,6 @@ void FontRenderer::appendRotatedMeshQuad(float x1, float y1, float u1, float v1, if (mCurrentQuadIndex == mMaxNumberOfQuads) { issueDrawCommand(); - mCurrentQuadIndex = 0; } } @@ -544,7 +558,6 @@ void FontRenderer::finishRender() { if (mCurrentQuadIndex != 0) { issueDrawCommand(); - mCurrentQuadIndex = 0; } } diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h index 405db09..09a3c25 100644 --- a/libs/hwui/FontRenderer.h +++ b/libs/hwui/FontRenderer.h @@ -138,6 +138,7 @@ private: void removeFont(const Font* font); + void updateDrawParams(); void checkTextureUpdate(); void setTextureDirty() { @@ -155,13 +156,13 @@ private: Vector<Font*> mActiveFonts; CacheTexture* mCurrentCacheTexture; - CacheTexture* mLastCacheTexture; bool mUploadTexture; // Pointer to vertex data to speed up frame to frame work float* mTextMesh; uint32_t mCurrentQuadIndex; + uint32_t mLastQuadIndex; uint32_t mMaxNumberOfQuads; uint32_t mIndexBufferID; @@ -174,6 +175,10 @@ private: bool mLinearFiltering; + Vector<uint16_t*> mDrawOffsets; + Vector<uint32_t> mDrawCounts; + Vector<CacheTexture*> mDrawCacheTextures; + /** We should consider multi-threading this code or using Renderscript **/ static void computeGaussianWeights(float* weights, int32_t radius); static void horizontalBlur(float* weights, int32_t radius, const uint8_t *source, uint8_t *dest, |