1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.support.v4.graphics.drawable; 18 19import android.content.res.Resources; 20import android.graphics.Bitmap; 21import android.graphics.Outline; 22import android.graphics.Rect; 23import android.view.Gravity; 24import android.view.View; 25 26class RoundedBitmapDrawable21 extends RoundedBitmapDrawable { 27 protected RoundedBitmapDrawable21(Resources res, Bitmap bitmap) { 28 super(res, bitmap); 29 } 30 31 @Override 32 public void getOutline(Outline outline) { 33 updateDstRect(); 34 outline.setRoundRect(mDstRect, getCornerRadius()); 35 } 36 37 @Override 38 public void setMipMap(boolean mipMap) { 39 if (mBitmap != null) { 40 mBitmap.setHasMipMap(mipMap); 41 invalidateSelf(); 42 } 43 } 44 45 @Override 46 public boolean hasMipMap() { 47 return mBitmap != null && mBitmap.hasMipMap(); 48 } 49 50 @Override 51 void gravityCompatApply(int gravity, int bitmapWidth, int bitmapHeight, 52 Rect bounds, Rect outRect) { 53 Gravity.apply(gravity, bitmapWidth, bitmapHeight, 54 bounds, outRect, View.LAYOUT_DIRECTION_LTR); 55 } 56} 57