am 94677083: Merge "Fix 9patch rendering in ExpandableListView." into honeycomb
* commit '94677083ab4c56ffef4a8a68d011d19333ab46c2': Fix 9patch rendering in ExpandableListView.
This commit is contained in:
@@ -22,7 +22,6 @@ import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -212,6 +211,9 @@ public class ExpandableListView extends ListView {
|
||||
.getDimensionPixelSize(com.android.internal.R.styleable.ExpandableListView_indicatorLeft, 0);
|
||||
mIndicatorRight = a
|
||||
.getDimensionPixelSize(com.android.internal.R.styleable.ExpandableListView_indicatorRight, 0);
|
||||
if (mIndicatorRight == 0) {
|
||||
mIndicatorRight = mIndicatorLeft + mGroupIndicator.getIntrinsicWidth();
|
||||
}
|
||||
mChildIndicatorLeft = a.getDimensionPixelSize(
|
||||
com.android.internal.R.styleable.ExpandableListView_childIndicatorLeft, CHILD_INDICATOR_INHERIT);
|
||||
mChildIndicatorRight = a.getDimensionPixelSize(
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
?android:attr/expandableListPreferredItemPaddingLeft</item>
|
||||
|
||||
<item name="expandableListPreferredItemIndicatorLeft">3dip</item>
|
||||
<item name="expandableListPreferredItemIndicatorRight">33dip</item>
|
||||
<item name="expandableListPreferredItemIndicatorRight">0dip</item>
|
||||
<item name="expandableListPreferredChildIndicatorLeft">
|
||||
?android:attr/expandableListPreferredItemIndicatorLeft</item>
|
||||
<item name="expandableListPreferredChildIndicatorRight">
|
||||
@@ -816,7 +816,7 @@
|
||||
?android:attr/expandableListPreferredItemPaddingLeft</item>
|
||||
|
||||
<item name="expandableListPreferredItemIndicatorLeft">3dip</item>
|
||||
<item name="expandableListPreferredItemIndicatorRight">33dip</item>
|
||||
<item name="expandableListPreferredItemIndicatorRight">0dip</item>
|
||||
<item name="expandableListPreferredChildIndicatorLeft">
|
||||
?android:attr/expandableListPreferredItemIndicatorLeft</item>
|
||||
<item name="expandableListPreferredChildIndicatorRight">
|
||||
@@ -1075,7 +1075,7 @@
|
||||
?android:attr/expandableListPreferredItemPaddingLeft</item>
|
||||
|
||||
<item name="expandableListPreferredItemIndicatorLeft">3dip</item>
|
||||
<item name="expandableListPreferredItemIndicatorRight">33dip</item>
|
||||
<item name="expandableListPreferredItemIndicatorRight">0dip</item>
|
||||
<item name="expandableListPreferredChildIndicatorLeft">
|
||||
?android:attr/expandableListPreferredItemIndicatorLeft</item>
|
||||
<item name="expandableListPreferredChildIndicatorRight">
|
||||
|
||||
@@ -37,6 +37,10 @@
|
||||
// Turn on to display vertex and tex coords data about 9patch objects
|
||||
// This flag requires DEBUG_PATCHES to be turned on
|
||||
#define DEBUG_PATCHES_VERTICES 0
|
||||
// Turn on to display vertex and tex coords data used by empty quads
|
||||
// in 9patch objects
|
||||
// This flag requires DEBUG_PATCHES to be turned on
|
||||
#define DEBUG_PATCHES_EMPTY_VERTICES 0
|
||||
|
||||
// Turn on to display debug info about paths
|
||||
#define DEBUG_PATHS 0
|
||||
|
||||
@@ -29,10 +29,6 @@ namespace uirenderer {
|
||||
void LayerRenderer::prepare(bool opaque) {
|
||||
LAYER_RENDERER_LOGD("Rendering into layer, fbo = %d", mLayer->fbo);
|
||||
|
||||
#if RENDER_LAYERS_AS_REGIONS
|
||||
mLayer->region.clear();
|
||||
#endif
|
||||
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &mPreviousFbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, mLayer->fbo);
|
||||
|
||||
@@ -78,6 +74,7 @@ void LayerRenderer::generateMesh() {
|
||||
mLayer->meshIndices = NULL;
|
||||
mLayer->meshElementCount = 0;
|
||||
}
|
||||
mLayer->region.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -129,6 +126,8 @@ void LayerRenderer::generateMesh() {
|
||||
indices[index + 4] = quad + 1; // top-right
|
||||
indices[index + 5] = quad + 3; // bottom-right
|
||||
}
|
||||
|
||||
mLayer->region.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, fl
|
||||
}
|
||||
float u2 = fmax(0.0f, stepX - 0.5f) / bitmapWidth;
|
||||
|
||||
generateQuad(vertex, x1, y1, x2, y2, u1, v1, u2, v2, quadCount);
|
||||
bool valid = generateQuad(vertex, x1, y1, x2, y2, u1, v1, u2, v2, quadCount);
|
||||
|
||||
x1 = x2;
|
||||
u1 = (stepX + 0.5f) / bitmapWidth;
|
||||
@@ -223,17 +223,22 @@ void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, fl
|
||||
generateQuad(vertex, x1, y1, width, y2, u1, v1, 1.0f, v2, quadCount);
|
||||
}
|
||||
|
||||
void Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2,
|
||||
bool Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2,
|
||||
float u1, float v1, float u2, float v2, uint32_t& quadCount) {
|
||||
const uint32_t oldQuadCount = quadCount;
|
||||
const bool valid = x2 - x1 > 0.9999f && y2 - y1 > 0.9999f;
|
||||
const bool valid = x2 >= x1 && y2 >= y1;
|
||||
if (valid) {
|
||||
quadCount++;
|
||||
}
|
||||
|
||||
// Skip degenerate and transparent (empty) quads
|
||||
if (!valid || ((mColorKey >> oldQuadCount) & 0x1) == 1) {
|
||||
return;
|
||||
#if DEBUG_PATCHES_EMPTY_VERTICES
|
||||
PATCH_LOGD(" quad %d (empty)", oldQuadCount);
|
||||
PATCH_LOGD(" left, top = %.2f, %.2f\t\tu1, v1 = %.2f, %.2f", x1, y1, u1, v1);
|
||||
PATCH_LOGD(" right, bottom = %.2f, %.2f\t\tu2, v2 = %.2f, %.2f", x2, y2, u2, v2);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#if RENDER_LAYERS_AS_REGIONS
|
||||
@@ -262,6 +267,8 @@ void Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, f
|
||||
PATCH_LOGD(" left, top = %.2f, %.2f\t\tu1, v1 = %.2f, %.2f", x1, y1, u1, v1);
|
||||
PATCH_LOGD(" right, bottom = %.2f, %.2f\t\tu2, v2 = %.2f, %.2f", x2, y2, u2, v2);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}; // namespace uirenderer
|
||||
|
||||
@@ -71,7 +71,7 @@ private:
|
||||
void generateRow(TextureVertex*& vertex, float y1, float y2,
|
||||
float v1, float v2, float stretchX, float width, float bitmapWidth,
|
||||
uint32_t& quadCount);
|
||||
void generateQuad(TextureVertex*& vertex,
|
||||
bool generateQuad(TextureVertex*& vertex,
|
||||
float x1, float y1, float x2, float y2,
|
||||
float u1, float v1, float u2, float v2,
|
||||
uint32_t& quadCount);
|
||||
|
||||
@@ -24,6 +24,16 @@
|
||||
android:label="HwUi"
|
||||
android:hardwareAccelerated="true">
|
||||
|
||||
<activity
|
||||
android:name="SimplePatchActivity"
|
||||
android:label="_SimplePatch"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="ViewLayersActivity"
|
||||
android:label="_ViewLayers">
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.android.test.hwui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public class SimplePatchActivity extends Activity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(new PatchView(this));
|
||||
}
|
||||
|
||||
private static class PatchView extends View {
|
||||
private final Drawable mDrawable;
|
||||
|
||||
public PatchView(Context context) {
|
||||
super(context);
|
||||
setBackgroundColor(0xff000000);
|
||||
mDrawable = context.getResources().getDrawable(R.drawable.expander_ic_minimized);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
canvas.save();
|
||||
canvas.translate(200, 200);
|
||||
mDrawable.setBounds(3, 0, 33, 64);
|
||||
mDrawable.draw(canvas);
|
||||
mDrawable.setBounds(63, 0, 94, 64);
|
||||
mDrawable.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user