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

Side by Side Diff: chrome/browser/webdata/web_database.cc

Issue 18347: Add a PNGEncoder helper function that takes an SkBitmap, (Closed)
Patch Set: Test2 Created 11 years, 11 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/importer/importer.cc ('k') | chrome/common/security_filter_peer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/webdata/web_database.h" 5 #include "chrome/browser/webdata/web_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 SQLStatement s; 194 SQLStatement s;
195 if (s.prepare(db_, 195 if (s.prepare(db_,
196 "INSERT OR REPLACE INTO web_app_icons " 196 "INSERT OR REPLACE INTO web_app_icons "
197 "(url, width, height, image) VALUES (?, ?, ?, ?)") 197 "(url, width, height, image) VALUES (?, ?, ?, ?)")
198 != SQLITE_OK) { 198 != SQLITE_OK) {
199 NOTREACHED() << "Statement prepare failed"; 199 NOTREACHED() << "Statement prepare failed";
200 return false; 200 return false;
201 } 201 }
202 202
203 std::vector<unsigned char> image_data; 203 std::vector<unsigned char> image_data;
204 204 PNGEncoder::EncodeBGRASkBitmap(image, false, &image_data);
205 SkAutoLockPixels pixel_lock(image);
206 PNGEncoder::Encode(reinterpret_cast<unsigned char*>(image.getPixels()),
207 PNGEncoder::FORMAT_BGRA, image.width(),
208 image.height(), image.width() * 4, false, &image_data);
209 205
210 s.bind_string(0, history::HistoryDatabase::GURLToDatabaseURL(url)); 206 s.bind_string(0, history::HistoryDatabase::GURLToDatabaseURL(url));
211 s.bind_int(1, image.width()); 207 s.bind_int(1, image.width());
212 s.bind_int(2, image.height()); 208 s.bind_int(2, image.height());
213 s.bind_blob(3, &image_data.front(), static_cast<int>(image_data.size())); 209 s.bind_blob(3, &image_data.front(), static_cast<int>(image_data.size()));
214 return s.step() == SQLITE_DONE; 210 return s.step() == SQLITE_DONE;
215 } 211 }
216 212
217 bool WebDatabase::GetWebAppImages(const GURL& url, 213 bool WebDatabase::GetWebAppImages(const GURL& url,
218 std::vector<SkBitmap>* images) { 214 std::vector<SkBitmap>* images) {
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 1130
1135 // Add successive versions here. Each should set the version number and 1131 // Add successive versions here. Each should set the version number and
1136 // compatible version number as appropriate, then fall through to the next 1132 // compatible version number as appropriate, then fall through to the next
1137 // case. 1133 // case.
1138 1134
1139 case kCurrentVersionNumber: 1135 case kCurrentVersionNumber:
1140 // No migration needed. 1136 // No migration needed.
1141 return; 1137 return;
1142 } 1138 }
1143 } 1139 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/importer.cc ('k') | chrome/common/security_filter_peer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698