diff options
-rw-r--r-- | core/java/android/view/ViewGroup.java | 8 | ||||
-rw-r--r-- | core/java/android/widget/ImageView.java | 34 | ||||
-rw-r--r-- | libs/hwui/Layer.h | 17 | ||||
-rw-r--r-- | libs/hwui/LayerRenderer.cpp | 14 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 6 |
5 files changed, 43 insertions, 36 deletions
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 7b404b45f729..1a84175a630e 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -2203,10 +2203,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } /** - * Perform dispatching of a {@link #saveHierarchyState freeze()} to only this view, - * not to its children. For use when overriding - * {@link #dispatchSaveInstanceState dispatchFreeze()} to allow subclasses to freeze - * their own state but not the state of their children. + * Perform dispatching of a {@link #saveHierarchyState(android.util.SparseArray)} freeze()} + * to only this view, not to its children. For use when overriding + * {@link #dispatchSaveInstanceState(android.util.SparseArray)} dispatchFreeze()} to allow + * subclasses to freeze their own state but not the state of their children. * * @param container the container */ diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 1fe6f4b47ec0..d8068f9ca353 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -218,15 +218,16 @@ public class ImageView extends View { /** * An optional argument to supply a maximum width for this view. Only valid if - * {@link #setAdjustViewBounds} has been set to true. To set an image to be a maximum of 100 x - * 100 while preserving the original aspect ratio, do the following: 1) set adjustViewBounds to - * true 2) set maxWidth and maxHeight to 100 3) set the height and width layout params to - * WRAP_CONTENT. + * {@link #setAdjustViewBounds(boolean)} has been set to true. To set an image to be a maximum + * of 100 x 100 while preserving the original aspect ratio, do the following: 1) set + * adjustViewBounds to true 2) set maxWidth and maxHeight to 100 3) set the height and width + * layout params to WRAP_CONTENT. * * <p> * Note that this view could be still smaller than 100 x 100 using this approach if the original * image is small. To set an image to a fixed size, specify that size in the layout params and - * then use {@link #setScaleType} to determine how to fit the image within the bounds. + * then use {@link #setScaleType(android.widget.ImageView.ScaleType)} to determine how to fit + * the image within the bounds. * </p> * * @param maxWidth maximum width for this view @@ -240,15 +241,16 @@ public class ImageView extends View { /** * An optional argument to supply a maximum height for this view. Only valid if - * {@link #setAdjustViewBounds} has been set to true. To set an image to be a maximum of 100 x - * 100 while preserving the original aspect ratio, do the following: 1) set adjustViewBounds to - * true 2) set maxWidth and maxHeight to 100 3) set the height and width layout params to - * WRAP_CONTENT. + * {@link #setAdjustViewBounds(boolean)} has been set to true. To set an image to be a + * maximum of 100 x 100 while preserving the original aspect ratio, do the following: 1) set + * adjustViewBounds to true 2) set maxWidth and maxHeight to 100 3) set the height and width + * layout params to WRAP_CONTENT. * * <p> * Note that this view could be still smaller than 100 x 100 using this approach if the original * image is small. To set an image to a fixed size, specify that size in the layout params and - * then use {@link #setScaleType} to determine how to fit the image within the bounds. + * then use {@link #setScaleType(android.widget.ImageView.ScaleType)} to determine how to fit + * the image within the bounds. * </p> * * @param maxHeight maximum height for this view @@ -272,8 +274,8 @@ public class ImageView extends View { * * <p class="note">This does Bitmap reading and decoding on the UI * thread, which can cause a latency hiccup. If that's a concern, - * consider using {@link #setImageDrawable} or - * {@link #setImageBitmap} and + * consider using {@link #setImageDrawable(android.graphics.drawable.Drawable)} or + * {@link #setImageBitmap(android.graphics.Bitmap)} and * {@link android.graphics.BitmapFactory} instead.</p> * * @param resId the resource identifier of the the drawable @@ -297,8 +299,8 @@ public class ImageView extends View { * * <p class="note">This does Bitmap reading and decoding on the UI * thread, which can cause a latency hiccup. If that's a concern, - * consider using {@link #setImageDrawable} or - * {@link #setImageBitmap} and + * consider using {@link #setImageDrawable(android.graphics.drawable.Drawable)} or + * {@link #setImageBitmap(android.graphics.Bitmap)} and * {@link android.graphics.BitmapFactory} instead.</p> * * @param uri The Uri of an image @@ -902,12 +904,12 @@ public class ImageView extends View { /** * <p>Set the offset of the widget's text baseline from the widget's top - * boundary. This value is overridden by the {@link #setBaselineAlignBottom} + * boundary. This value is overridden by the {@link #setBaselineAlignBottom(boolean)} * property.</p> * * @param baseline The baseline to use, or -1 if none is to be provided. * - * @see #setBaseline + * @see #setBaseline(int) * @attr ref android.R.styleable#ImageView_baseline */ public void setBaseline(int baseline) { diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index 26e240f2be99..6c4a2a9a972d 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -53,6 +53,23 @@ struct Layer { } /** + * Sets this layer's region to a rectangle. Computes the appropriate + * texture coordinates. + */ + void setRegionAsRect() { + const android::Rect& bounds = region.getBounds(); + regionRect.set(bounds.leftTop().x, bounds.leftTop().y, + bounds.rightBottom().x, bounds.rightBottom().y); + + const float texX = 1.0f / float(width); + const float texY = 1.0f / float(height); + const float height = layer.getHeight(); + texCoords.set( + regionRect.left * texX, (height - regionRect.top) * texY, + regionRect.right * texX, (height - regionRect.bottom) * texY); + } + + /** * Bounds of the layer. */ Rect layer; diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp index ba110ec0efae..ca1e7ae0027b 100644 --- a/libs/hwui/LayerRenderer.cpp +++ b/libs/hwui/LayerRenderer.cpp @@ -102,19 +102,7 @@ void LayerRenderer::generateMesh() { mLayer->meshElementCount = 0; } - const android::Rect& bounds = mLayer->region.getBounds(); - mLayer->regionRect.set(bounds.leftTop().x, bounds.leftTop().y, - bounds.rightBottom().x, bounds.rightBottom().y); - - const float texX = 1.0f / float(mLayer->width); - const float texY = 1.0f / float(mLayer->height); - const float height = mLayer->layer.getHeight(); - mLayer->texCoords.set( - mLayer->regionRect.left * texX, - (height - mLayer->regionRect.top) * texY, - mLayer->regionRect.right * texX, - (height - mLayer->regionRect.bottom) * texY); - + mLayer->setRegionAsRect(); return; } diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index dd0cca22738c..e926d9915bad 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -647,10 +647,10 @@ void OpenGLRenderer::composeLayerRect(Layer* layer, const Rect& rect, bool swap) void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) { #if RENDER_LAYERS_AS_REGIONS if (layer->region.isRect()) { - const android::Rect& bounds = layer->region.getBounds(); - layer->regionRect.set(bounds.leftTop().x, bounds.leftTop().y, - bounds.rightBottom().x, bounds.rightBottom().y); + layer->setRegionAsRect(); + composeLayerRect(layer, layer->regionRect); + layer->region.clear(); return; } |