OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/android/thumbnail/thumbnail_cache.h" | 5 #include "chrome/browser/android/thumbnail/thumbnail_cache.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/big_endian.h" | 10 #include "base/big_endian.h" |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 DCHECK(!bitmap.empty()); | 907 DCHECK(!bitmap.empty()); |
908 DCHECK_GT(scale, 0); | 908 DCHECK_GT(scale, 0); |
909 SkAutoLockPixels bitmap_lock(bitmap); | 909 SkAutoLockPixels bitmap_lock(bitmap); |
910 float new_scale = 1.f / kApproximationScaleFactor; | 910 float new_scale = 1.f / kApproximationScaleFactor; |
911 | 911 |
912 gfx::Size dst_size = gfx::ToFlooredSize( | 912 gfx::Size dst_size = gfx::ToFlooredSize( |
913 gfx::ScaleSize(gfx::Size(bitmap.width(), bitmap.height()), new_scale)); | 913 gfx::ScaleSize(gfx::Size(bitmap.width(), bitmap.height()), new_scale)); |
914 SkBitmap dst_bitmap; | 914 SkBitmap dst_bitmap; |
915 dst_bitmap.allocPixels(SkImageInfo::Make(dst_size.width(), | 915 dst_bitmap.allocPixels(SkImageInfo::Make(dst_size.width(), |
916 dst_size.height(), | 916 dst_size.height(), |
917 bitmap.info().fColorType, | 917 bitmap.info().colorType(), |
918 bitmap.info().fAlphaType)); | 918 bitmap.info().alphaType())); |
919 dst_bitmap.eraseColor(0); | 919 dst_bitmap.eraseColor(0); |
920 SkAutoLockPixels dst_bitmap_lock(dst_bitmap); | 920 SkAutoLockPixels dst_bitmap_lock(dst_bitmap); |
921 | 921 |
922 SkCanvas canvas(dst_bitmap); | 922 SkCanvas canvas(dst_bitmap); |
923 canvas.scale(new_scale, new_scale); | 923 canvas.scale(new_scale, new_scale); |
924 canvas.drawBitmap(bitmap, 0, 0, NULL); | 924 canvas.drawBitmap(bitmap, 0, 0, NULL); |
925 dst_bitmap.setImmutable(); | 925 dst_bitmap.setImmutable(); |
926 | 926 |
927 return std::make_pair(dst_bitmap, new_scale * scale); | 927 return std::make_pair(dst_bitmap, new_scale * scale); |
928 } | 928 } |
OLD | NEW |