diff options
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 8 | ||||
-rw-r--r-- | libs/hwui/SkiaShader.cpp | 7 | ||||
-rw-r--r-- | tests/HwAccelerationTest/AndroidManifest.xml | 9 | ||||
-rw-r--r-- | tests/HwAccelerationTest/res/layout/text_fade.xml | 38 | ||||
-rw-r--r-- | tests/HwAccelerationTest/src/com/android/test/hwui/TextFadeActivity.java | 34 |
5 files changed, 93 insertions, 3 deletions
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/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/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml index 9fcd05a..d74d80d 100644 --- a/tests/HwAccelerationTest/AndroidManifest.xml +++ b/tests/HwAccelerationTest/AndroidManifest.xml @@ -31,6 +31,15 @@ android:hardwareAccelerated="true"> <activity + android:name="TextFadeActivity" + android:label="_TextFade"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + + <activity android:name="MaxBitmapSizeActivity" android:label="_MaxBitmapSize"> <intent-filter> diff --git a/tests/HwAccelerationTest/res/layout/text_fade.xml b/tests/HwAccelerationTest/res/layout/text_fade.xml new file mode 100644 index 0000000..8da2204 --- /dev/null +++ b/tests/HwAccelerationTest/res/layout/text_fade.xml @@ -0,0 +1,38 @@ +<?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. +--> + +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <TextView + android:id="@+id/contact_tile_name" + android:layout_width="105dip" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentLeft="true" + android:layout_marginLeft="8dip" + android:layout_marginBottom="20dip" + android:textColor="@android:color/white" + android:singleLine="true" + android:ellipsize="marquee" + android:fadingEdgeLength="16sp" + android:fadingEdge="horizontal" + android:text="This is a really really really really really really long string" + android:textSize="16sp" /> + +</FrameLayout> diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextFadeActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextFadeActivity.java new file mode 100644 index 0000000..c8bbc7d --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextFadeActivity.java @@ -0,0 +1,34 @@ +/* + * 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.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.os.Bundle; +import android.view.View; + +@SuppressWarnings({"UnusedDeclaration"}) +public class TextFadeActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.text_fade); + } +} |