OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/gfx/android/java_bitmap.h" | 5 #include "ui/gfx/android/java_bitmap.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include "base/android/sys_utils.h" | |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "jni/BitmapHelper_jni.h" | 11 #include "jni/BitmapHelper_jni.h" |
11 #include "skia/ext/image_operations.h" | 12 #include "skia/ext/image_operations.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
14 | 15 |
15 using base::android::AttachCurrentThread; | 16 using base::android::AttachCurrentThread; |
16 | 17 |
17 namespace gfx { | 18 namespace gfx { |
18 | 19 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, | 85 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, |
85 src_size.width(), src_size.height(), src_lock.stride()); | 86 src_size.width(), src_size.height(), src_lock.stride()); |
86 skbitmap.allocPixels(); | 87 skbitmap.allocPixels(); |
87 SkAutoLockPixels dst_lock(skbitmap); | 88 SkAutoLockPixels dst_lock(skbitmap); |
88 | 89 |
89 void* src_pixels = src_lock.pixels(); | 90 void* src_pixels = src_lock.pixels(); |
90 void* dst_pixels = skbitmap.getPixels(); | 91 void* dst_pixels = skbitmap.getPixels(); |
91 | 92 |
92 memcpy(dst_pixels, src_pixels, skbitmap.getSize()); | 93 memcpy(dst_pixels, src_pixels, skbitmap.getSize()); |
93 | 94 |
95 if (base::android::SysUtils::IsLowEndDevice()) { | |
Sami
2013/09/05 14:13:26
Is this mainly for UI resources? You could conside
kaanb
2013/09/06 02:05:54
Done.
| |
96 SkBitmap bitmap_16; | |
97 skbitmap.copyTo(&bitmap_16, SkBitmap::kARGB_4444_Config); | |
98 return bitmap_16; | |
99 } | |
100 | |
94 return skbitmap; | 101 return skbitmap; |
95 } | 102 } |
96 | 103 |
97 SkBitmap CreateSkBitmapFromResource(const char* name, gfx::Size size) { | 104 SkBitmap CreateSkBitmapFromResource(const char* name, gfx::Size size) { |
98 DCHECK(!size.IsEmpty()); | 105 DCHECK(!size.IsEmpty()); |
99 SkBitmap bitmap = | 106 SkBitmap bitmap = |
100 ConvertToSkBitmap(CreateJavaBitmapFromResource(name, size)); | 107 ConvertToSkBitmap(CreateJavaBitmapFromResource(name, size)); |
101 if (bitmap.isNull()) | 108 if (bitmap.isNull()) |
102 return bitmap; | 109 return bitmap; |
103 // RESIZE_BOX has sufficient downsampling quality with minimal runtime cost. | 110 // RESIZE_BOX has sufficient downsampling quality with minimal runtime cost. |
104 return skia::ImageOperations::Resize(bitmap, | 111 return skia::ImageOperations::Resize(bitmap, |
Sami
2013/09/05 14:13:26
Should we do 16 bit here too?
kaanb
2013/09/06 02:05:54
Removed this file from the patch since the overscr
| |
105 skia::ImageOperations::RESIZE_BOX, | 112 skia::ImageOperations::RESIZE_BOX, |
106 size.width(), size.height()); | 113 size.width(), size.height()); |
107 } | 114 } |
108 | 115 |
109 } // namespace gfx | 116 } // namespace gfx |
OLD | NEW |