| 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/image/image_util.h" | 5 #include "ui/gfx/image/image_util.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 const gfx::ImageSkiaRep& image_skia_rep = | 59 const gfx::ImageSkiaRep& image_skia_rep = |
| 60 image.AsImageSkia().GetRepresentation(1.0f); | 60 image.AsImageSkia().GetRepresentation(1.0f); |
| 61 if (image_skia_rep.scale() != 1.0f) | 61 if (image_skia_rep.scale() != 1.0f) |
| 62 return false; | 62 return false; |
| 63 | 63 |
| 64 const SkBitmap& bitmap = image_skia_rep.sk_bitmap(); | 64 const SkBitmap& bitmap = image_skia_rep.sk_bitmap(); |
| 65 if (!bitmap.readyToDraw()) | 65 if (!bitmap.readyToDraw()) |
| 66 return false; | 66 return false; |
| 67 | 67 |
| 68 return gfx::JPEGCodec::Encode( | 68 return gfx::JPEGCodec::Encode( |
| 69 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), | 69 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), |
| 70 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), | 70 kN32_SkColorType, bitmap.width(), bitmap.height(), |
| 71 bitmap.height(), | 71 static_cast<int>(bitmap.rowBytes()), quality, dst); |
| 72 static_cast<int>(bitmap.rowBytes()), quality, | |
| 73 dst); | |
| 74 } | 72 } |
| 75 #endif // !defined(OS_IOS) | 73 #endif // !defined(OS_IOS) |
| 76 | 74 |
| 77 void GetVisibleMargins(const ImageSkia& image, int* left, int* right) { | 75 void GetVisibleMargins(const ImageSkia& image, int* left, int* right) { |
| 78 *left = 0; | 76 *left = 0; |
| 79 *right = 0; | 77 *right = 0; |
| 80 if (!image.HasRepresentation(1.f)) | 78 if (!image.HasRepresentation(1.f)) |
| 81 return; | 79 return; |
| 82 const SkBitmap& bitmap = image.GetRepresentation(1.f).sk_bitmap(); | 80 const SkBitmap& bitmap = image.GetRepresentation(1.f).sk_bitmap(); |
| 83 if (bitmap.drawsNothing() || bitmap.isOpaque()) | 81 if (bitmap.drawsNothing() || bitmap.isOpaque()) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 102 // Since we already know column *left is non-transparent, we can avoid | 100 // Since we already know column *left is non-transparent, we can avoid |
| 103 // rechecking that column; hence the '>' here. | 101 // rechecking that column; hence the '>' here. |
| 104 for (x = bitmap.width() - 1; x > *left; --x) { | 102 for (x = bitmap.width() - 1; x > *left; --x) { |
| 105 if (ColumnHasVisiblePixels(bitmap, x)) | 103 if (ColumnHasVisiblePixels(bitmap, x)) |
| 106 break; | 104 break; |
| 107 } | 105 } |
| 108 *right = bitmap.width() - 1 - x; | 106 *right = bitmap.width() - 1 - x; |
| 109 } | 107 } |
| 110 | 108 |
| 111 } // namespace gfx | 109 } // namespace gfx |
| OLD | NEW |