Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Unified Diff: components/suggestions/image_manager.cc

Issue 641513003: [Suggestions] Introduce a different image encoder/decoder for iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/suggestions/DEPS ('k') | components/suggestions/image_manager_utils_ios.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/suggestions/image_manager.cc
diff --git a/components/suggestions/image_manager.cc b/components/suggestions/image_manager.cc
index 9e4338127d35e4fcce065d010f06a66a5fe01ecb..b27a4c41d5d142b366968cbfbc5c0a752f3c25a4 100644
--- a/components/suggestions/image_manager.cc
+++ b/components/suggestions/image_manager.cc
@@ -6,15 +6,24 @@
#include "base/bind.h"
#include "components/suggestions/image_fetcher.h"
+
+#if defined(OS_IOS)
+#include "components/suggestions/image_manager_utils_ios.h"
+#else
#include "ui/gfx/codec/jpeg_codec.h"
+#endif
using leveldb_proto::ProtoDatabase;
namespace {
-// From JPEG-encoded bytes to SkBitmap.
+// From encoded bytes to SkBitmap.
SkBitmap* DecodeImage(const std::vector<unsigned char>& encoded_data) {
+#if defined(OS_IOS)
+ return suggestions::DecodeJPEGToSkBitmap(encoded_data);
blundell 2014/10/10 06:01:05 nit: this should be in the suggestions namespace,
Mathieu 2014/10/10 18:06:10 Done.
+#else
return gfx::JPEGCodec::Decode(&encoded_data[0], encoded_data.size());
+#endif
}
} // namespace
@@ -215,6 +224,9 @@ void ImageManager::ServePendingCacheRequests() {
// static
bool ImageManager::EncodeImage(const SkBitmap& bitmap,
std::vector<unsigned char>* dest) {
+#if defined(OS_IOS)
+ return suggestions::EncodeSkBitmapToJPEG(bitmap, dest);
blundell 2014/10/10 06:01:05 this is in the suggestions namespace.
Mathieu 2014/10/10 18:06:10 Done.
+#else
SkAutoLockPixels bitmap_lock(bitmap);
if (!bitmap.readyToDraw() || bitmap.isNull()) {
return false;
@@ -223,6 +235,7 @@ bool ImageManager::EncodeImage(const SkBitmap& bitmap,
reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)),
gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(),
bitmap.rowBytes(), 100, dest);
+#endif
}
} // namespace suggestions
« no previous file with comments | « components/suggestions/DEPS ('k') | components/suggestions/image_manager_utils_ios.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698