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

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

Merge "Add new mipMap attribute to BitmapDrawable"

parents 86ee9f37 5769fcd8
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -723,6 +723,7 @@ package android {
    field public static final int minResizeWidth = 16843669; // 0x1010395
    field public static final int minSdkVersion = 16843276; // 0x101020c
    field public static final int minWidth = 16843071; // 0x101013f
    field public static final int mipMap = 16843725; // 0x10103cd
    field public static final int mode = 16843134; // 0x101017e
    field public static final int moreIcon = 16843061; // 0x1010135
    field public static final int multiprocess = 16842771; // 0x1010013
@@ -9344,10 +9345,13 @@ package android.graphics.drawable {
    method public final android.graphics.Paint getPaint();
    method public android.graphics.Shader.TileMode getTileModeX();
    method public android.graphics.Shader.TileMode getTileModeY();
    method public boolean hasAntiAlias();
    method public boolean hasMipMap();
    method public void setAlpha(int);
    method public void setAntiAlias(boolean);
    method public void setColorFilter(android.graphics.ColorFilter);
    method public void setGravity(int);
    method public void setMipMap(boolean);
    method public void setTargetDensity(android.graphics.Canvas);
    method public void setTargetDensity(android.util.DisplayMetrics);
    method public void setTargetDensity(int);
+9 −4
Original line number Diff line number Diff line
@@ -4030,20 +4030,21 @@
    <declare-styleable name="BitmapDrawable">
        <!-- Identifier of the bitmap file. This attribute is mandatory. -->
        <attr name="src" />
        <!-- Enables or disables antialiasing. -->
        <!-- Enables or disables antialiasing. Antialiasing can be used to smooth the
             edges of a bitmap when rotated. Default value is false. -->
        <attr name="antialias" format="boolean" />
        <!-- Enables or disables bitmap filtering. Filtering is used when the bitmap is
             shrunk or stretched to smooth its apperance. -->
             shrunk or stretched to smooth its apperance. Default value is true. -->
        <attr name="filter" format="boolean" />
        <!-- Enables or disables dithering of the bitmap if the bitmap does not have the
             same pixel configuration as the screen (for instance: a ARGB 8888 bitmap with
             an RGB 565 screen). -->
             an RGB 565 screen). Default value is true. -->
        <attr name="dither" />
        <!-- Defines the gravity for the bitmap. The gravity indicates where to position
             the drawable in its container if the bitmap is smaller than the container. -->
        <attr name="gravity" />
        <!-- Defines the tile mode. When the tile mode is enabled, the bitmap is repeated.
             Gravity is ignored when the tile mode is enabled. -->
             Gravity is ignored when the tile mode is enabled. Default value is "disabled". -->
        <attr name="tileMode">
            <!-- Do not tile the bitmap. This is the default value. -->
            <enum name="disabled" value="-1" />
@@ -4055,6 +4056,10 @@
                 mirror images so that adjacent images always seam. -->
            <enum name="mirror" value="2" />
        </attr>
        <!-- Enables or disables the mipmap hint. See
            {@link android.graphics.Bitmap#setHasMipMap(boolean)} for more information.
            Default value is false. -->
        <attr name="mipMap" format="boolean" />
    </declare-styleable>

    <!-- Drawable used to draw 9-patches. -->
+7 −0
Original line number Diff line number Diff line
@@ -2028,4 +2028,11 @@
  <public type="style" name="Widget.DeviceDefault.CheckedTextView" id="0x010301db" />
  <public type="style" name="Widget.DeviceDefault.Light.CheckedTextView" id="0x010301dc" />

<!-- ===============================================================
     Resources added in version 18 of the platform
     =============================================================== -->
  <eat-comment />

  <public type="attr" name="mipMap" id="0x010103cd" />

</resources>
+46 −2
Original line number Diff line number Diff line
@@ -256,17 +256,59 @@ public class BitmapDrawable extends Drawable {
        }
    }

    /**
     * Enables or disables the mipmap hint for this drawable's bitmap.
     * See {@link Bitmap#setHasMipMap(boolean)} for more information.
     *
     * If the bitmap is null calling this method has no effect.
     *
     * @param mipMap True if the bitmap should use mipmaps, false otherwise.
     *
     * @see #hasMipMap() 
     */
    public void setMipMap(boolean mipMap) {
        if (mBitmapState.mBitmap != null) {
            mBitmapState.mBitmap.setHasMipMap(mipMap);
            invalidateSelf();
        }
    }

    /**
     * Indicates whether the mipmap hint is enabled on this drawable's bitmap.
     *
     * @return True if the mipmap hint is set, false otherwise. If the bitmap
     *         is null, this method always returns false.
     *
     * @see #setMipMap(boolean) 
     */
    public boolean hasMipMap() {
        return mBitmapState.mBitmap != null && mBitmapState.mBitmap.hasMipMap();
    }

    /**
     * Enables or disables anti-aliasing for this drawable. Anti-aliasing affects
     * the edges of the bitmap only so it applies only when the drawable is rotated.
     * 
     * @param aa True if the bitmap should be anti-aliased, false otherwise.
     *
     * @see #hasAntiAlias() 
     */
    public void setAntiAlias(boolean aa) {
        mBitmapState.mPaint.setAntiAlias(aa);
        invalidateSelf();
    }

    /**
     * Indicates whether anti-aliasing is enabled for this drawable.
     *
     * @return True if anti-aliasing is enabled, false otherwise.
     *
     * @see #setAntiAlias(boolean)
     */
    public boolean hasAntiAlias() {
        return mBitmapState.mPaint.isAntiAlias();
    }

    @Override
    public void setFilterBitmap(boolean filter) {
        mBitmapState.mPaint.setFilterBitmap(filter);
@@ -451,6 +493,8 @@ public class BitmapDrawable extends Drawable {
        mBitmapState.mBitmap = bitmap;
        setBitmap(bitmap);
        setTargetDensity(r.getDisplayMetrics());
        setMipMap(a.getBoolean(com.android.internal.R.styleable.BitmapDrawable_mipMap,
                bitmap.hasMipMap()));

        final Paint paint = mBitmapState.mPaint;
        paint.setAntiAlias(a.getBoolean(com.android.internal.R.styleable.BitmapDrawable_antialias,