Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ef1ce49 authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Correctly compute tex coords for rect layers. Bug #4192695"

parents b4a56f10 9fc27819
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -2203,10 +2203,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
    }
    }


    /**
    /**
     * Perform dispatching of a {@link #saveHierarchyState freeze()} to only this view,
     * Perform dispatching of a {@link #saveHierarchyState(android.util.SparseArray)}  freeze()}
     * not to its children.  For use when overriding
     * to only this view, not to its children.  For use when overriding
     * {@link #dispatchSaveInstanceState dispatchFreeze()} to allow subclasses to freeze
     * {@link #dispatchSaveInstanceState(android.util.SparseArray)}  dispatchFreeze()} to allow
     * their own state but not the state of their children.
     * subclasses to freeze their own state but not the state of their children.
     *
     *
     * @param container the container
     * @param container the container
     */
     */
+18 −16
Original line number Original line Diff line number Diff line
@@ -218,15 +218,16 @@ public class ImageView extends View {
    
    
    /**
    /**
     * An optional argument to supply a maximum width for this view. Only valid if
     * 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
     * {@link #setAdjustViewBounds(boolean)} has been set to true. To set an image to be a maximum
     * 100 while preserving the original aspect ratio, do the following: 1) set adjustViewBounds to
     * of 100 x 100 while preserving the original aspect ratio, do the following: 1) set
     * true 2) set maxWidth and maxHeight to 100 3) set the height and width layout params to
     * adjustViewBounds to true 2) set maxWidth and maxHeight to 100 3) set the height and width
     * WRAP_CONTENT.
     * layout params to WRAP_CONTENT.
     * 
     * 
     * <p>
     * <p>
     * Note that this view could be still smaller than 100 x 100 using this approach if the original
     * 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
     * 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>
     * </p>
     * 
     * 
     * @param maxWidth maximum width for this view
     * @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
     * 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
     * {@link #setAdjustViewBounds(boolean)} has been set to true. To set an image to be a
     * 100 while preserving the original aspect ratio, do the following: 1) set adjustViewBounds to
     * maximum of 100 x 100 while preserving the original aspect ratio, do the following: 1) set
     * true 2) set maxWidth and maxHeight to 100 3) set the height and width layout params to
     * adjustViewBounds to true 2) set maxWidth and maxHeight to 100 3) set the height and width
     * WRAP_CONTENT.
     * layout params to WRAP_CONTENT.
     * 
     * 
     * <p>
     * <p>
     * Note that this view could be still smaller than 100 x 100 using this approach if the original
     * 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
     * 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>
     * </p>
     * 
     * 
     * @param maxHeight maximum height for this view
     * @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
     * <p class="note">This does Bitmap reading and decoding on the UI
     * thread, which can cause a latency hiccup.  If that's a concern,
     * thread, which can cause a latency hiccup.  If that's a concern,
     * consider using {@link #setImageDrawable} or
     * consider using {@link #setImageDrawable(android.graphics.drawable.Drawable)} or
     * {@link #setImageBitmap} and
     * {@link #setImageBitmap(android.graphics.Bitmap)} and
     * {@link android.graphics.BitmapFactory} instead.</p>
     * {@link android.graphics.BitmapFactory} instead.</p>
     *
     *
     * @param resId the resource identifier of the the drawable
     * @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
     * <p class="note">This does Bitmap reading and decoding on the UI
     * thread, which can cause a latency hiccup.  If that's a concern,
     * thread, which can cause a latency hiccup.  If that's a concern,
     * consider using {@link #setImageDrawable} or
     * consider using {@link #setImageDrawable(android.graphics.drawable.Drawable)} or
     * {@link #setImageBitmap} and
     * {@link #setImageBitmap(android.graphics.Bitmap)} and
     * {@link android.graphics.BitmapFactory} instead.</p>
     * {@link android.graphics.BitmapFactory} instead.</p>
     *
     *
     * @param uri The Uri of an image
     * @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
     * <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>
     * property.</p>
     *
     *
     * @param baseline The baseline to use, or -1 if none is to be provided.
     * @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
     * @attr ref android.R.styleable#ImageView_baseline
     */
     */
    public void setBaseline(int baseline) {
    public void setBaseline(int baseline) {
+17 −0
Original line number Original line Diff line number Diff line
@@ -52,6 +52,23 @@ struct Layer {
        if (meshIndices) delete meshIndices;
        if (meshIndices) delete meshIndices;
    }
    }


    /**
     * 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.
     * Bounds of the layer.
     */
     */
+1 −13
Original line number Original line Diff line number Diff line
@@ -102,19 +102,7 @@ void LayerRenderer::generateMesh() {
            mLayer->meshElementCount = 0;
            mLayer->meshElementCount = 0;
        }
        }


        const android::Rect& bounds = mLayer->region.getBounds();
        mLayer->setRegionAsRect();
        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);

        return;
        return;
    }
    }


+3 −3
Original line number Original line Diff line number Diff line
@@ -647,10 +647,10 @@ void OpenGLRenderer::composeLayerRect(Layer* layer, const Rect& rect, bool swap)
void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) {
void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) {
#if RENDER_LAYERS_AS_REGIONS
#if RENDER_LAYERS_AS_REGIONS
    if (layer->region.isRect()) {
    if (layer->region.isRect()) {
        const android::Rect& bounds = layer->region.getBounds();
        layer->setRegionAsRect();
        layer->regionRect.set(bounds.leftTop().x, bounds.leftTop().y,

                bounds.rightBottom().x, bounds.rightBottom().y);
        composeLayerRect(layer, layer->regionRect);
        composeLayerRect(layer, layer->regionRect);

        layer->region.clear();
        layer->region.clear();
        return;
        return;
    }
    }