diff options
| -rw-r--r-- | libs/hwui/DisplayListRenderer.cpp | 56 | ||||
| -rw-r--r-- | libs/hwui/DisplayListRenderer.h | 48 | ||||
| -rw-r--r-- | libs/hwui/FontRenderer.cpp | 21 | ||||
| -rw-r--r-- | libs/hwui/FontRenderer.h | 10 | ||||
| -rw-r--r-- | tests/HwAccelerationTest/AndroidManifest.xml | 9 | ||||
| -rw-r--r-- | tests/HwAccelerationTest/res/layout/labels.xml | 45 | ||||
| -rw-r--r-- | tests/HwAccelerationTest/src/com/android/test/hwui/LabelsActivity.java | 29 |
7 files changed, 160 insertions, 58 deletions
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index ee90702..ce85d46 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -22,6 +22,62 @@ namespace android { namespace uirenderer { /////////////////////////////////////////////////////////////////////////////// +// Defines +/////////////////////////////////////////////////////////////////////////////// + +#define PATH_HEAP_SIZE 64 + +/////////////////////////////////////////////////////////////////////////////// +// Helpers +/////////////////////////////////////////////////////////////////////////////// + +PathHeap::PathHeap(): mHeap(PATH_HEAP_SIZE * sizeof(SkPath)) { +} + +PathHeap::PathHeap(SkFlattenableReadBuffer& buffer): mHeap(PATH_HEAP_SIZE * sizeof(SkPath)) { + int count = buffer.readS32(); + + mPaths.setCount(count); + SkPath** ptr = mPaths.begin(); + SkPath* p = (SkPath*) mHeap.allocThrow(count * sizeof(SkPath)); + + for (int i = 0; i < count; i++) { + new (p) SkPath; + p->unflatten(buffer); + *ptr++ = p; + p++; + } +} + +PathHeap::~PathHeap() { + SkPath** iter = mPaths.begin(); + SkPath** stop = mPaths.end(); + while (iter < stop) { + (*iter)->~SkPath(); + iter++; + } +} + +int PathHeap::append(const SkPath& path) { + SkPath* p = (SkPath*) mHeap.allocThrow(sizeof(SkPath)); + new (p) SkPath(path); + *mPaths.append() = p; + return mPaths.count(); +} + +void PathHeap::flatten(SkFlattenableWriteBuffer& buffer) const { + int count = mPaths.count(); + + buffer.write32(count); + SkPath** iter = mPaths.begin(); + SkPath** stop = mPaths.end(); + while (iter < stop) { + (*iter)->flatten(buffer); + iter++; + } +} + +/////////////////////////////////////////////////////////////////////////////// // Display list /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index 735f0e7..5d02bd7 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -45,39 +45,11 @@ namespace uirenderer { class PathHeap: public SkRefCnt { public: - PathHeap(): mHeap(64 * sizeof(SkPath)) { - }; - - PathHeap(SkFlattenableReadBuffer& buffer): mHeap(64 * sizeof(SkPath)) { - int count = buffer.readS32(); - - mPaths.setCount(count); - SkPath** ptr = mPaths.begin(); - SkPath* p = (SkPath*) mHeap.allocThrow(count * sizeof(SkPath)); - - for (int i = 0; i < count; i++) { - new (p) SkPath; - p->unflatten(buffer); - *ptr++ = p; - p++; - } - } + PathHeap(); + PathHeap(SkFlattenableReadBuffer& buffer); + ~PathHeap(); - ~PathHeap() { - SkPath** iter = mPaths.begin(); - SkPath** stop = mPaths.end(); - while (iter < stop) { - (*iter)->~SkPath(); - iter++; - } - } - - int append(const SkPath& path) { - SkPath* p = (SkPath*) mHeap.allocThrow(sizeof(SkPath)); - new (p) SkPath(path); - *mPaths.append() = p; - return mPaths.count(); - } + int append(const SkPath& path); int count() const { return mPaths.count(); } @@ -85,17 +57,7 @@ public: return *mPaths[index]; } - void flatten(SkFlattenableWriteBuffer& buffer) const { - int count = mPaths.count(); - - buffer.write32(count); - SkPath** iter = mPaths.begin(); - SkPath** stop = mPaths.end(); - while (iter < stop) { - (*iter)->flatten(buffer); - iter++; - } - } + void flatten(SkFlattenableWriteBuffer& buffer) const; private: SkChunkAlloc mHeap; diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index b66696d..4e4a277 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -435,25 +435,25 @@ void FontRenderer::initTextTexture() { glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, mCacheWidth, mCacheHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Split up our cache texture into lines of certain widths int nextLine = 0; - mCacheLines.push(new CacheTextureLine(mCacheWidth, 16, nextLine, 0)); + mCacheLines.push(new CacheTextureLine(mCacheWidth, 18, nextLine, 0)); nextLine += mCacheLines.top()->mMaxHeight; - mCacheLines.push(new CacheTextureLine(mCacheWidth, 24, nextLine, 0)); + mCacheLines.push(new CacheTextureLine(mCacheWidth, 26, nextLine, 0)); nextLine += mCacheLines.top()->mMaxHeight; - mCacheLines.push(new CacheTextureLine(mCacheWidth, 24, nextLine, 0)); + mCacheLines.push(new CacheTextureLine(mCacheWidth, 26, nextLine, 0)); nextLine += mCacheLines.top()->mMaxHeight; - mCacheLines.push(new CacheTextureLine(mCacheWidth, 32, nextLine, 0)); + mCacheLines.push(new CacheTextureLine(mCacheWidth, 34, nextLine, 0)); nextLine += mCacheLines.top()->mMaxHeight; - mCacheLines.push(new CacheTextureLine(mCacheWidth, 32, nextLine, 0)); + mCacheLines.push(new CacheTextureLine(mCacheWidth, 34, nextLine, 0)); nextLine += mCacheLines.top()->mMaxHeight; - mCacheLines.push(new CacheTextureLine(mCacheWidth, 40, nextLine, 0)); + mCacheLines.push(new CacheTextureLine(mCacheWidth, 42, nextLine, 0)); nextLine += mCacheLines.top()->mMaxHeight; mCacheLines.push(new CacheTextureLine(mCacheWidth, mCacheHeight - nextLine, nextLine, 0)); } @@ -631,6 +631,7 @@ void FontRenderer::setFont(SkPaint* paint, uint32_t fontId, float fontSize) { precacheLatin(paint); } } + FontRenderer::DropShadow FontRenderer::renderDropShadow(SkPaint* paint, const char *text, uint32_t startIndex, uint32_t len, int numGlyphs, uint32_t radius) { checkInit(); @@ -713,7 +714,7 @@ void FontRenderer::computeGaussianWeights(float* weights, int32_t radius) { float normalizeFactor = 0.0f; for(int32_t r = -radius; r <= radius; r ++) { - float floatR = (float)r; + float floatR = (float) r; weights[r + radius] = coeff1 * pow(e, floatR * floatR * coeff2); normalizeFactor += weights[r + radius]; } @@ -742,7 +743,7 @@ void FontRenderer::horizontalBlur(float* weights, int32_t radius, if ((x > radius) && (x < (width - radius))) { const uint8_t *i = input + (x - radius); for(int r = -radius; r <= radius; r ++) { - currentPixel = (float)(*i); + currentPixel = (float) (*i); blurredPixel += currentPixel * gPtr[0]; gPtr++; i++; diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h index de5c019..4fb8f8d 100644 --- a/libs/hwui/FontRenderer.h +++ b/libs/hwui/FontRenderer.h @@ -183,14 +183,14 @@ protected: } bool fitBitmap(const SkGlyph& glyph, uint32_t *retOriginX, uint32_t *retOriginY) { - if (glyph.fHeight > mMaxHeight) { + if (glyph.fHeight + 2 > mMaxHeight) { return false; } - if (mCurrentCol + glyph.fWidth < mMaxWidth) { - *retOriginX = mCurrentCol; - *retOriginY = mCurrentRow; - mCurrentCol += glyph.fWidth; + if (mCurrentCol + glyph.fWidth + 2 < mMaxWidth) { + *retOriginX = mCurrentCol + 1; + *retOriginY = mCurrentRow + 1; + mCurrentCol += glyph.fWidth + 2; mDirty = true; return true; } diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml index 4be41b9..df3c3ed 100644 --- a/tests/HwAccelerationTest/AndroidManifest.xml +++ b/tests/HwAccelerationTest/AndroidManifest.xml @@ -40,6 +40,15 @@ </activity> <activity + android:name="LabelsActivity" + android:label="_Labels"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + + <activity android:name="ResizeActivity" android:label="_Resize" android:windowSoftInputMode="adjustResize"> diff --git a/tests/HwAccelerationTest/res/layout/labels.xml b/tests/HwAccelerationTest/res/layout/labels.xml new file mode 100644 index 0000000..695a2cc --- /dev/null +++ b/tests/HwAccelerationTest/res/layout/labels.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- 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. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <TextView + android:layout_width="200dip" + android:layout_height="wrap_content" + android:singleLine="true" + android:ellipsize="marquee" + android:text="This is a long text view for ellipsizing" /> + + <TextView + android:layout_width="200dip" + android:layout_height="wrap_content" + android:singleLine="true" + android:ellipsize="marquee" + android:gravity="center_horizontal" + android:text="This is a very long text view for ellipsizing" /> + + <TextView + android:layout_width="200dip" + android:layout_height="wrap_content" + android:singleLine="true" + android:ellipsize="marquee" + android:gravity="right" + android:text="This is a very long text view for ellipsizing" /> + +</LinearLayout> diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/LabelsActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/LabelsActivity.java new file mode 100644 index 0000000..bae0500 --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/LabelsActivity.java @@ -0,0 +1,29 @@ +/* + * 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. + */ + +package com.android.test.hwui; + +import android.app.Activity; +import android.os.Bundle; + +@SuppressWarnings({"UnusedDeclaration"}) +public class LabelsActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.labels); + } +} |
