OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.photo_picker; | 5 package org.chromium.chrome.browser.photo_picker; |
6 | 6 |
7 import android.content.res.Resources; | 7 import android.content.res.Resources; |
8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
9 import android.os.AsyncTask; | 9 import android.os.AsyncTask; |
| 10 import android.os.SystemClock; |
10 import android.support.v7.widget.RecyclerView.ViewHolder; | 11 import android.support.v7.widget.RecyclerView.ViewHolder; |
11 import android.text.TextUtils; | 12 import android.text.TextUtils; |
12 | 13 |
| 14 import org.chromium.base.metrics.RecordHistogram; |
13 import org.chromium.chrome.R; | 15 import org.chromium.chrome.R; |
14 | 16 |
15 import java.util.List; | 17 import java.util.List; |
| 18 import java.util.concurrent.TimeUnit; |
16 | 19 |
17 /** | 20 /** |
18 * Holds on to a {@link PickerBitmapView} that displays information about a pick
er bitmap. | 21 * Holds on to a {@link PickerBitmapView} that displays information about a pick
er bitmap. |
19 */ | 22 */ |
20 public class PickerBitmapViewHolder | 23 public class PickerBitmapViewHolder |
21 extends ViewHolder implements DecoderServiceHost.ImageDecodedCallback { | 24 extends ViewHolder implements DecoderServiceHost.ImageDecodedCallback { |
22 // Our parent category. | 25 // Our parent category. |
23 private PickerCategoryView mCategoryView; | 26 private PickerCategoryView mCategoryView; |
24 | 27 |
25 // The bitmap view we are holding on to. | 28 // The bitmap view we are holding on to. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 Bitmap original = mCategoryView.getHighResBitmaps().get(filePath); | 89 Bitmap original = mCategoryView.getHighResBitmaps().get(filePath); |
87 if (original != null) { | 90 if (original != null) { |
88 mItemView.initialize(mBitmapDetails, original, false); | 91 mItemView.initialize(mBitmapDetails, original, false); |
89 return; | 92 return; |
90 } | 93 } |
91 | 94 |
92 int size = mCategoryView.getImageSize(); | 95 int size = mCategoryView.getImageSize(); |
93 Bitmap placeholder = mCategoryView.getLowResBitmaps().get(filePath); | 96 Bitmap placeholder = mCategoryView.getLowResBitmaps().get(filePath); |
94 if (placeholder != null) { | 97 if (placeholder != null) { |
95 // For performance stats see http://crbug.com/719919. | 98 // For performance stats see http://crbug.com/719919. |
| 99 long begin = SystemClock.elapsedRealtime(); |
96 placeholder = BitmapUtils.scale(placeholder, size, false); | 100 placeholder = BitmapUtils.scale(placeholder, size, false); |
| 101 long scaleTime = SystemClock.elapsedRealtime() - begin; |
| 102 RecordHistogram.recordTimesHistogram( |
| 103 "Android.PhotoPicker.UpscaleLowResBitmap", scaleTime, TimeUn
it.MILLISECONDS); |
| 104 |
97 mItemView.initialize(mBitmapDetails, placeholder, true); | 105 mItemView.initialize(mBitmapDetails, placeholder, true); |
98 } else { | 106 } else { |
99 mItemView.initialize(mBitmapDetails, null, true); | 107 mItemView.initialize(mBitmapDetails, null, true); |
100 } | 108 } |
101 | 109 |
102 mCategoryView.getDecoderServiceHost().decodeImage(filePath, size, this); | 110 mCategoryView.getDecoderServiceHost().decodeImage(filePath, size, this); |
103 } | 111 } |
104 | 112 |
105 /** | 113 /** |
106 * Returns the file path of the current request. | 114 * Returns the file path of the current request. |
107 */ | 115 */ |
108 public String getFilePath() { | 116 public String getFilePath() { |
109 return mBitmapDetails == null ? null : mBitmapDetails.getFilePath(); | 117 return mBitmapDetails == null ? null : mBitmapDetails.getFilePath(); |
110 } | 118 } |
111 } | 119 } |
OLD | NEW |