| Index: components/suggestions/image_manager.cc
|
| diff --git a/components/suggestions/image_manager.cc b/components/suggestions/image_manager.cc
|
| index 9e4338127d35e4fcce065d010f06a66a5fe01ecb..5309e0bb790d05a2ac8e903cbd8d09bba9701be9 100644
|
| --- a/components/suggestions/image_manager.cc
|
| +++ b/components/suggestions/image_manager.cc
|
| @@ -6,18 +6,14 @@
|
|
|
| #include "base/bind.h"
|
| #include "components/suggestions/image_fetcher.h"
|
| -#include "ui/gfx/codec/jpeg_codec.h"
|
|
|
| -using leveldb_proto::ProtoDatabase;
|
| -
|
| -namespace {
|
| -
|
| -// From JPEG-encoded bytes to SkBitmap.
|
| -SkBitmap* DecodeImage(const std::vector<unsigned char>& encoded_data) {
|
| - return gfx::JPEGCodec::Decode(&encoded_data[0], encoded_data.size());
|
| -}
|
| +#if defined(OS_IOS)
|
| +#include "components/suggestions/image_encoder_ios.h"
|
| +#else
|
| +#include "components/suggestions/image_encoder.h"
|
| +#endif
|
|
|
| -} // namespace
|
| +using leveldb_proto::ProtoDatabase;
|
|
|
| namespace suggestions {
|
|
|
| @@ -139,7 +135,7 @@ void ImageManager::SaveImage(const GURL& url, const SkBitmap& bitmap) {
|
| // Attempt to save a JPEG representation to the database. If not successful,
|
| // the fetched bitmap will still be inserted in the cache, above.
|
| std::vector<unsigned char> encoded_data;
|
| - if (EncodeImage(bitmap, &encoded_data)) {
|
| + if (EncodeSkBitmapToJPEG(bitmap, &encoded_data)) {
|
| // Save the resulting bitmap to the database.
|
| ImageData data;
|
| data.set_url(url.spec());
|
| @@ -194,7 +190,7 @@ void ImageManager::LoadEntriesInCache(scoped_ptr<ImageDataVector> entries) {
|
| std::vector<unsigned char> encoded_data(it->data().begin(),
|
| it->data().end());
|
|
|
| - scoped_ptr<SkBitmap> bitmap(DecodeImage(encoded_data));
|
| + scoped_ptr<SkBitmap> bitmap(DecodeJPEGToSkBitmap(encoded_data));
|
| if (bitmap.get()) {
|
| image_map_.insert(std::make_pair(it->url(), *bitmap));
|
| }
|
| @@ -212,17 +208,4 @@ void ImageManager::ServePendingCacheRequests() {
|
| }
|
| }
|
|
|
| -// static
|
| -bool ImageManager::EncodeImage(const SkBitmap& bitmap,
|
| - std::vector<unsigned char>* dest) {
|
| - SkAutoLockPixels bitmap_lock(bitmap);
|
| - if (!bitmap.readyToDraw() || bitmap.isNull()) {
|
| - return false;
|
| - }
|
| - return gfx::JPEGCodec::Encode(
|
| - reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)),
|
| - gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(),
|
| - bitmap.rowBytes(), 100, dest);
|
| -}
|
| -
|
| } // namespace suggestions
|
|
|