NinePatchDrawable.java revision 8bb399069da4e46b231333cff6880a0cf35b9417
1/* 2 * Copyright (C) 2006 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.graphics.drawable; 18 19import android.annotation.NonNull; 20import android.content.res.ColorStateList; 21import android.content.res.Resources; 22import android.content.res.Resources.Theme; 23import android.content.res.TypedArray; 24import android.graphics.Bitmap; 25import android.graphics.BitmapFactory; 26import android.graphics.Canvas; 27import android.graphics.ColorFilter; 28import android.graphics.Insets; 29import android.graphics.NinePatch; 30import android.graphics.Outline; 31import android.graphics.Paint; 32import android.graphics.PixelFormat; 33import android.graphics.PorterDuff; 34import android.graphics.PorterDuff.Mode; 35import android.graphics.PorterDuffColorFilter; 36import android.graphics.Rect; 37import android.graphics.Region; 38import android.util.AttributeSet; 39import android.util.DisplayMetrics; 40import android.util.LayoutDirection; 41import android.util.TypedValue; 42 43import com.android.internal.R; 44 45import org.xmlpull.v1.XmlPullParser; 46import org.xmlpull.v1.XmlPullParserException; 47 48import java.io.IOException; 49import java.io.InputStream; 50 51/** 52 * 53 * A resizeable bitmap, with stretchable areas that you define. This type of image 54 * is defined in a .png file with a special format. 55 * 56 * <div class="special reference"> 57 * <h3>Developer Guides</h3> 58 * <p>For more information about how to use a NinePatchDrawable, read the 59 * <a href="{@docRoot}guide/topics/graphics/2d-graphics.html#nine-patch"> 60 * Canvas and Drawables</a> developer guide. For information about creating a NinePatch image 61 * file using the draw9patch tool, see the 62 * <a href="{@docRoot}guide/developing/tools/draw9patch.html">Draw 9-patch</a> tool guide.</p></div> 63 */ 64public class NinePatchDrawable extends Drawable { 65 // dithering helps a lot, and is pretty cheap, so default is true 66 private static final boolean DEFAULT_DITHER = false; 67 private NinePatchState mNinePatchState; 68 private NinePatch mNinePatch; 69 private PorterDuffColorFilter mTintFilter; 70 private Rect mPadding; 71 private Insets mOpticalInsets = Insets.NONE; 72 private Paint mPaint; 73 private boolean mMutated; 74 75 private int mTargetDensity = DisplayMetrics.DENSITY_DEFAULT; 76 77 // These are scaled to match the target density. 78 private int mBitmapWidth = -1; 79 private int mBitmapHeight = -1; 80 81 NinePatchDrawable() { 82 mNinePatchState = new NinePatchState(); 83 } 84 85 /** 86 * Create drawable from raw nine-patch data, not dealing with density. 87 * @deprecated Use {@link #NinePatchDrawable(Resources, Bitmap, byte[], Rect, String)} 88 * to ensure that the drawable has correctly set its target density. 89 */ 90 @Deprecated 91 public NinePatchDrawable(Bitmap bitmap, byte[] chunk, Rect padding, String srcName) { 92 this(new NinePatchState(new NinePatch(bitmap, chunk, srcName), padding), null, null); 93 } 94 95 /** 96 * Create drawable from raw nine-patch data, setting initial target density 97 * based on the display metrics of the resources. 98 */ 99 public NinePatchDrawable(Resources res, Bitmap bitmap, byte[] chunk, 100 Rect padding, String srcName) { 101 this(new NinePatchState(new NinePatch(bitmap, chunk, srcName), padding), res, null); 102 mNinePatchState.mTargetDensity = mTargetDensity; 103 } 104 105 /** 106 * Create drawable from raw nine-patch data, setting initial target density 107 * based on the display metrics of the resources. 108 * 109 * @hide 110 */ 111 public NinePatchDrawable(Resources res, Bitmap bitmap, byte[] chunk, 112 Rect padding, Rect opticalInsets, String srcName) { 113 this(new NinePatchState(new NinePatch(bitmap, chunk, srcName), padding, opticalInsets), 114 res, null); 115 mNinePatchState.mTargetDensity = mTargetDensity; 116 } 117 118 /** 119 * Create drawable from existing nine-patch, not dealing with density. 120 * @deprecated Use {@link #NinePatchDrawable(Resources, NinePatch)} 121 * to ensure that the drawable has correctly set its target density. 122 */ 123 @Deprecated 124 public NinePatchDrawable(NinePatch patch) { 125 this(new NinePatchState(patch, new Rect()), null, null); 126 } 127 128 /** 129 * Create drawable from existing nine-patch, setting initial target density 130 * based on the display metrics of the resources. 131 */ 132 public NinePatchDrawable(Resources res, NinePatch patch) { 133 this(new NinePatchState(patch, new Rect()), res, null); 134 mNinePatchState.mTargetDensity = mTargetDensity; 135 } 136 137 /** 138 * Set the density scale at which this drawable will be rendered. This 139 * method assumes the drawable will be rendered at the same density as the 140 * specified canvas. 141 * 142 * @param canvas The Canvas from which the density scale must be obtained. 143 * 144 * @see android.graphics.Bitmap#setDensity(int) 145 * @see android.graphics.Bitmap#getDensity() 146 */ 147 public void setTargetDensity(Canvas canvas) { 148 setTargetDensity(canvas.getDensity()); 149 } 150 151 /** 152 * Set the density scale at which this drawable will be rendered. 153 * 154 * @param metrics The DisplayMetrics indicating the density scale for this drawable. 155 * 156 * @see android.graphics.Bitmap#setDensity(int) 157 * @see android.graphics.Bitmap#getDensity() 158 */ 159 public void setTargetDensity(DisplayMetrics metrics) { 160 setTargetDensity(metrics.densityDpi); 161 } 162 163 /** 164 * Set the density at which this drawable will be rendered. 165 * 166 * @param density The density scale for this drawable. 167 * 168 * @see android.graphics.Bitmap#setDensity(int) 169 * @see android.graphics.Bitmap#getDensity() 170 */ 171 public void setTargetDensity(int density) { 172 if (density != mTargetDensity) { 173 mTargetDensity = density == 0 ? DisplayMetrics.DENSITY_DEFAULT : density; 174 if (mNinePatch != null) { 175 computeBitmapSize(); 176 } 177 invalidateSelf(); 178 } 179 } 180 181 private static Insets scaleFromDensity(Insets insets, int sdensity, int tdensity) { 182 int left = Bitmap.scaleFromDensity(insets.left, sdensity, tdensity); 183 int top = Bitmap.scaleFromDensity(insets.top, sdensity, tdensity); 184 int right = Bitmap.scaleFromDensity(insets.right, sdensity, tdensity); 185 int bottom = Bitmap.scaleFromDensity(insets.bottom, sdensity, tdensity); 186 return Insets.of(left, top, right, bottom); 187 } 188 189 private void computeBitmapSize() { 190 final int sdensity = mNinePatch.getDensity(); 191 final int tdensity = mTargetDensity; 192 if (sdensity == tdensity) { 193 mBitmapWidth = mNinePatch.getWidth(); 194 mBitmapHeight = mNinePatch.getHeight(); 195 mOpticalInsets = mNinePatchState.mOpticalInsets; 196 } else { 197 mBitmapWidth = Bitmap.scaleFromDensity(mNinePatch.getWidth(), sdensity, tdensity); 198 mBitmapHeight = Bitmap.scaleFromDensity(mNinePatch.getHeight(), sdensity, tdensity); 199 if (mNinePatchState.mPadding != null && mPadding != null) { 200 Rect dest = mPadding; 201 Rect src = mNinePatchState.mPadding; 202 if (dest == src) { 203 mPadding = dest = new Rect(src); 204 } 205 dest.left = Bitmap.scaleFromDensity(src.left, sdensity, tdensity); 206 dest.top = Bitmap.scaleFromDensity(src.top, sdensity, tdensity); 207 dest.right = Bitmap.scaleFromDensity(src.right, sdensity, tdensity); 208 dest.bottom = Bitmap.scaleFromDensity(src.bottom, sdensity, tdensity); 209 } 210 mOpticalInsets = scaleFromDensity(mNinePatchState.mOpticalInsets, sdensity, tdensity); 211 } 212 } 213 214 private void setNinePatch(NinePatch ninePatch) { 215 if (mNinePatch != ninePatch) { 216 mNinePatch = ninePatch; 217 if (ninePatch != null) { 218 computeBitmapSize(); 219 } else { 220 mBitmapWidth = mBitmapHeight = -1; 221 mOpticalInsets = Insets.NONE; 222 } 223 invalidateSelf(); 224 } 225 } 226 227 @Override 228 public void draw(Canvas canvas) { 229 final Rect bounds = getBounds(); 230 231 final boolean clearColorFilter; 232 if (mTintFilter != null && getPaint().getColorFilter() == null) { 233 mPaint.setColorFilter(mTintFilter); 234 clearColorFilter = true; 235 } else { 236 clearColorFilter = false; 237 } 238 239 final boolean needsMirroring = needsMirroring(); 240 if (needsMirroring) { 241 // Mirror the 9patch 242 canvas.translate(bounds.right - bounds.left, 0); 243 canvas.scale(-1.0f, 1.0f); 244 } 245 246 final int restoreAlpha; 247 if (mNinePatchState.mBaseAlpha != 1.0f) { 248 restoreAlpha = mPaint.getAlpha(); 249 mPaint.setAlpha((int) (restoreAlpha * mNinePatchState.mBaseAlpha + 0.5f)); 250 } else { 251 restoreAlpha = -1; 252 } 253 254 mNinePatch.draw(canvas, bounds, mPaint); 255 256 if (clearColorFilter) { 257 mPaint.setColorFilter(null); 258 } 259 260 if (restoreAlpha >= 0) { 261 mPaint.setAlpha(restoreAlpha); 262 } 263 } 264 265 @Override 266 public int getChangingConfigurations() { 267 return super.getChangingConfigurations() | mNinePatchState.mChangingConfigurations; 268 } 269 270 @Override 271 public boolean getPadding(Rect padding) { 272 final Rect scaledPadding = mPadding; 273 if (scaledPadding != null) { 274 if (needsMirroring()) { 275 padding.set(scaledPadding.right, scaledPadding.top, 276 scaledPadding.left, scaledPadding.bottom); 277 } else { 278 padding.set(scaledPadding); 279 } 280 return (padding.left | padding.top | padding.right | padding.bottom) != 0; 281 } 282 return false; 283 } 284 285 @Override 286 public void getOutline(@NonNull Outline outline) { 287 final Rect bounds = getBounds(); 288 if (bounds.isEmpty()) return; 289 290 if (mNinePatchState != null) { 291 NinePatch.InsetStruct insets = mNinePatchState.getBitmap().getNinePatchInsets(); 292 if (insets != null) { 293 final Rect outlineInsets = insets.outlineRect; 294 outline.setRoundRect(bounds.left + outlineInsets.left, 295 bounds.top + outlineInsets.top, 296 bounds.right - outlineInsets.right, 297 bounds.bottom - outlineInsets.bottom, 298 insets.outlineRadius); 299 outline.setFilled(insets.outlineFilled); 300 return; 301 } 302 } 303 super.getOutline(outline); 304 } 305 306 /** 307 * @hide 308 */ 309 @Override 310 public Insets getOpticalInsets() { 311 if (needsMirroring()) { 312 return Insets.of(mOpticalInsets.right, mOpticalInsets.top, 313 mOpticalInsets.left, mOpticalInsets.bottom); 314 } else { 315 return mOpticalInsets; 316 } 317 } 318 319 @Override 320 public void setAlpha(int alpha) { 321 if (mPaint == null && alpha == 0xFF) { 322 // Fast common case -- leave at normal alpha. 323 return; 324 } 325 getPaint().setAlpha(alpha); 326 invalidateSelf(); 327 } 328 329 @Override 330 public int getAlpha() { 331 if (mPaint == null) { 332 // Fast common case -- normal alpha. 333 return 0xFF; 334 } 335 return getPaint().getAlpha(); 336 } 337 338 @Override 339 public void setColorFilter(ColorFilter cf) { 340 if (mPaint == null && cf == null) { 341 // Fast common case -- leave at no color filter. 342 return; 343 } 344 getPaint().setColorFilter(cf); 345 invalidateSelf(); 346 } 347 348 @Override 349 public void setTint(ColorStateList tint, PorterDuff.Mode tintMode) { 350 final NinePatchState state = mNinePatchState; 351 state.mTint = tint; 352 state.mTintMode = tintMode; 353 354 mTintFilter = updateTintFilter(mTintFilter, tint, tintMode); 355 invalidateSelf(); 356 } 357 358 @Override 359 public void setDither(boolean dither) { 360 //noinspection PointlessBooleanExpression 361 if (mPaint == null && dither == DEFAULT_DITHER) { 362 // Fast common case -- leave at default dither. 363 return; 364 } 365 366 getPaint().setDither(dither); 367 invalidateSelf(); 368 } 369 370 @Override 371 public void setAutoMirrored(boolean mirrored) { 372 mNinePatchState.mAutoMirrored = mirrored; 373 } 374 375 private boolean needsMirroring() { 376 return isAutoMirrored() && getLayoutDirection() == LayoutDirection.RTL; 377 } 378 379 @Override 380 public boolean isAutoMirrored() { 381 return mNinePatchState.mAutoMirrored; 382 } 383 384 @Override 385 public void setFilterBitmap(boolean filter) { 386 getPaint().setFilterBitmap(filter); 387 invalidateSelf(); 388 } 389 390 @Override 391 public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme) 392 throws XmlPullParserException, IOException { 393 super.inflate(r, parser, attrs, theme); 394 395 final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.NinePatchDrawable); 396 updateStateFromTypedArray(a); 397 a.recycle(); 398 } 399 400 /** 401 * Updates the constant state from the values in the typed array. 402 */ 403 private void updateStateFromTypedArray(TypedArray a) throws XmlPullParserException { 404 final Resources r = a.getResources(); 405 final NinePatchState state = mNinePatchState; 406 407 // Account for any configuration changes. 408 state.mChangingConfigurations |= a.getChangingConfigurations(); 409 410 // Extract the theme attributes, if any. 411 state.mThemeAttrs = a.extractThemeAttrs(); 412 413 state.mDither = a.getBoolean(R.styleable.NinePatchDrawable_dither, state.mDither); 414 415 final int srcResId = a.getResourceId(R.styleable.NinePatchDrawable_src, 0); 416 if (srcResId != 0) { 417 final BitmapFactory.Options options = new BitmapFactory.Options(); 418 options.inDither = !state.mDither; 419 options.inScreenDensity = r.getDisplayMetrics().noncompatDensityDpi; 420 421 final Rect padding = new Rect(); 422 final Rect opticalInsets = new Rect(); 423 Bitmap bitmap = null; 424 425 try { 426 final TypedValue value = new TypedValue(); 427 final InputStream is = r.openRawResource(srcResId, value); 428 429 bitmap = BitmapFactory.decodeResourceStream(r, value, is, padding, options); 430 431 is.close(); 432 } catch (IOException e) { 433 // Ignore 434 } 435 436 if (bitmap == null) { 437 throw new XmlPullParserException(a.getPositionDescription() + 438 ": <nine-patch> requires a valid src attribute"); 439 } else if (bitmap.getNinePatchChunk() == null) { 440 throw new XmlPullParserException(a.getPositionDescription() + 441 ": <nine-patch> requires a valid 9-patch source image"); 442 } 443 444 // Hey, now might be a good time to actually load optical bounds! 445 bitmap.getOpticalInsets(opticalInsets); 446 447 // Sanity check for valid padding when we have optical insets. 448 if (padding.left < opticalInsets.left) { 449 padding.left = opticalInsets.left; 450 padding.right = opticalInsets.right; 451 } 452 if (padding.top < opticalInsets.top) { 453 padding.top = opticalInsets.top; 454 padding.bottom = opticalInsets.bottom; 455 } 456 457 state.mNinePatch = new NinePatch(bitmap, bitmap.getNinePatchChunk()); 458 state.mPadding = padding; 459 state.mOpticalInsets = Insets.of(opticalInsets); 460 } 461 462 state.mAutoMirrored = a.getBoolean( 463 R.styleable.NinePatchDrawable_autoMirrored, state.mAutoMirrored); 464 state.mBaseAlpha = a.getFloat(R.styleable.NinePatchDrawable_alpha, state.mBaseAlpha); 465 466 final int tintMode = a.getInt(R.styleable.NinePatchDrawable_tintMode, -1); 467 if (tintMode != -1) { 468 state.mTintMode = Drawable.parseTintMode(tintMode, Mode.SRC_IN); 469 } 470 471 final ColorStateList tint = a.getColorStateList(R.styleable.NinePatchDrawable_tint); 472 if (tint != null) { 473 state.mTint = tint; 474 } 475 476 // Update local properties. 477 initializeWithState(state, r); 478 479 // Push density applied by setNinePatchState into state. 480 state.mTargetDensity = mTargetDensity; 481 } 482 483 @Override 484 public void applyTheme(Theme t) { 485 super.applyTheme(t); 486 487 final NinePatchState state = mNinePatchState; 488 if (state == null || state.mThemeAttrs == null) { 489 return; 490 } 491 492 final TypedArray a = t.resolveAttributes(state.mThemeAttrs, R.styleable.NinePatchDrawable); 493 try { 494 updateStateFromTypedArray(a); 495 } catch (XmlPullParserException e) { 496 throw new RuntimeException(e); 497 } finally { 498 a.recycle(); 499 } 500 } 501 502 @Override 503 public boolean canApplyTheme() { 504 return mNinePatchState != null && mNinePatchState.mThemeAttrs != null; 505 } 506 507 public Paint getPaint() { 508 if (mPaint == null) { 509 mPaint = new Paint(); 510 mPaint.setDither(DEFAULT_DITHER); 511 } 512 return mPaint; 513 } 514 515 /** 516 * Retrieves the width of the source .png file (before resizing). 517 */ 518 @Override 519 public int getIntrinsicWidth() { 520 return mBitmapWidth; 521 } 522 523 /** 524 * Retrieves the height of the source .png file (before resizing). 525 */ 526 @Override 527 public int getIntrinsicHeight() { 528 return mBitmapHeight; 529 } 530 531 @Override 532 public int getMinimumWidth() { 533 return mBitmapWidth; 534 } 535 536 @Override 537 public int getMinimumHeight() { 538 return mBitmapHeight; 539 } 540 541 /** 542 * Returns a {@link android.graphics.PixelFormat graphics.PixelFormat} 543 * value of OPAQUE or TRANSLUCENT. 544 */ 545 @Override 546 public int getOpacity() { 547 return mNinePatch.hasAlpha() || (mPaint != null && mPaint.getAlpha() < 255) ? 548 PixelFormat.TRANSLUCENT : PixelFormat.OPAQUE; 549 } 550 551 @Override 552 public Region getTransparentRegion() { 553 return mNinePatch.getTransparentRegion(getBounds()); 554 } 555 556 @Override 557 public ConstantState getConstantState() { 558 mNinePatchState.mChangingConfigurations = getChangingConfigurations(); 559 return mNinePatchState; 560 } 561 562 @Override 563 public Drawable mutate() { 564 if (!mMutated && super.mutate() == this) { 565 mNinePatchState = new NinePatchState(mNinePatchState); 566 mNinePatch = mNinePatchState.mNinePatch; 567 mMutated = true; 568 } 569 return this; 570 } 571 572 @Override 573 protected boolean onStateChange(int[] stateSet) { 574 final NinePatchState state = mNinePatchState; 575 if (state.mTint != null && state.mTintMode != null) { 576 mTintFilter = updateTintFilter(mTintFilter, state.mTint, state.mTintMode); 577 return true; 578 } 579 580 return false; 581 } 582 583 @Override 584 public boolean isStateful() { 585 final NinePatchState s = mNinePatchState; 586 return super.isStateful() || (s.mTint != null && s.mTint.isStateful()); 587 } 588 589 final static class NinePatchState extends ConstantState { 590 // Values loaded during inflation. 591 int[] mThemeAttrs = null; 592 NinePatch mNinePatch = null; 593 ColorStateList mTint = null; 594 Mode mTintMode = Mode.SRC_IN; 595 Rect mPadding = null; 596 Insets mOpticalInsets = Insets.NONE; 597 float mBaseAlpha = 1.0f; 598 boolean mDither = DEFAULT_DITHER; 599 int mTargetDensity = DisplayMetrics.DENSITY_DEFAULT; 600 boolean mAutoMirrored = false; 601 602 int mChangingConfigurations; 603 604 NinePatchState() { 605 // Empty constructor. 606 } 607 608 NinePatchState(NinePatch ninePatch, Rect padding) { 609 this(ninePatch, padding, null, DEFAULT_DITHER, false); 610 } 611 612 NinePatchState(NinePatch ninePatch, Rect padding, Rect opticalInsets) { 613 this(ninePatch, padding, opticalInsets, DEFAULT_DITHER, false); 614 } 615 616 NinePatchState(NinePatch ninePatch, Rect rect, Rect opticalInsets, boolean dither, 617 boolean autoMirror) { 618 mNinePatch = ninePatch; 619 mPadding = rect; 620 mOpticalInsets = Insets.of(opticalInsets); 621 mDither = dither; 622 mAutoMirrored = autoMirror; 623 624 // Sanity check for valid padding when we have optical insets. 625 if (mPadding.left < mOpticalInsets.left) { 626 mPadding.left = mOpticalInsets.left; 627 mPadding.right = mOpticalInsets.right; 628 } 629 if (mPadding.top < mOpticalInsets.top) { 630 mPadding.top = mOpticalInsets.top; 631 mPadding.bottom = mOpticalInsets.bottom; 632 } 633 } 634 635 // Copy constructor 636 637 NinePatchState(NinePatchState state) { 638 // We don't deep-copy any fields because they are all immutable. 639 mNinePatch = state.mNinePatch; 640 mTint = state.mTint; 641 mTintMode = state.mTintMode; 642 mThemeAttrs = state.mThemeAttrs; 643 mPadding = state.mPadding; 644 mOpticalInsets = state.mOpticalInsets; 645 mBaseAlpha = state.mBaseAlpha; 646 mDither = state.mDither; 647 mChangingConfigurations = state.mChangingConfigurations; 648 mTargetDensity = state.mTargetDensity; 649 mAutoMirrored = state.mAutoMirrored; 650 } 651 652 @Override 653 public boolean canApplyTheme() { 654 return mThemeAttrs != null; 655 } 656 657 @Override 658 public Bitmap getBitmap() { 659 return mNinePatch.getBitmap(); 660 } 661 662 @Override 663 public Drawable newDrawable() { 664 return new NinePatchDrawable(this, null, null); 665 } 666 667 @Override 668 public Drawable newDrawable(Resources res) { 669 return new NinePatchDrawable(this, res, null); 670 } 671 672 @Override 673 public Drawable newDrawable(Resources res, Theme theme) { 674 return new NinePatchDrawable(this, res, theme); 675 } 676 677 @Override 678 public int getChangingConfigurations() { 679 return mChangingConfigurations; 680 } 681 } 682 683 /** 684 * The one constructor to rule them all. This is called by all public 685 * constructors to set the state and initialize local properties. 686 */ 687 private NinePatchDrawable(NinePatchState state, Resources res, Theme theme) { 688 if (theme != null && state.canApplyTheme()) { 689 // If we need to apply a theme, implicitly mutate. 690 mNinePatchState = new NinePatchState(state); 691 applyTheme(theme); 692 } else { 693 mNinePatchState = state; 694 } 695 696 initializeWithState(state, res); 697 } 698 699 /** 700 * Initializes local dynamic properties from state. 701 */ 702 private void initializeWithState(NinePatchState state, Resources res) { 703 if (res != null) { 704 mTargetDensity = res.getDisplayMetrics().densityDpi; 705 } else { 706 mTargetDensity = state.mTargetDensity; 707 } 708 709 // If we can, avoid calling any methods that initialize Paint. 710 if (state.mDither != DEFAULT_DITHER) { 711 setDither(state.mDither); 712 } 713 714 // Make a local copy of the padding. 715 if (state.mPadding != null) { 716 mPadding = new Rect(state.mPadding); 717 } 718 719 mTintFilter = updateTintFilter(mTintFilter, state.mTint, state.mTintMode); 720 setNinePatch(state.mNinePatch); 721 } 722} 723