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

Unified Diff: cc/resources/picture.cc

Issue 15496006: Use the new function signature for EncodeBitmap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | « no previous file | content/renderer/gpu/gpu_benchmarking_extension.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/picture.cc
diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc
index 748e404166b6a0f676e3c41242ccdda7828176fa..e149c2599729cac2ee27b4ef68c86fdc1fa7e0b9 100644
--- a/cc/resources/picture.cc
+++ b/cc/resources/picture.cc
@@ -39,7 +39,7 @@ const int kPictureVersion = 1;
// 4 bytes for version, 4 * 4 for each of the 2 rects.
const unsigned int kMinPictureSizeBytes = 36;
-bool EncodeBitmap(SkWStream* stream, const SkBitmap& bm) {
+SkData* EncodeBitmap(size_t* offset, const SkBitmap& bm) {
const int kJpegQuality = 80;
std::vector<unsigned char> data;
@@ -49,7 +49,7 @@ bool EncodeBitmap(SkWStream* stream, const SkBitmap& bm) {
if (bm.isOpaque()) {
SkAutoLockPixels lock_bitmap(bm);
if (bm.empty())
- return false;
+ return NULL;
encoding_succeeded = gfx::JPEGCodec::Encode(
reinterpret_cast<unsigned char*>(bm.getAddr32(0, 0)),
@@ -63,9 +63,11 @@ bool EncodeBitmap(SkWStream* stream, const SkBitmap& bm) {
encoding_succeeded = gfx::PNGCodec::EncodeBGRASkBitmap(bm, false, &data);
}
- if (encoding_succeeded)
- return stream->write(&data.front(), data.size());
- return false;
+ if (encoding_succeeded) {
+ *offset = 0;
+ return SkData::NewWithCopy(&data.front(), data.size());
+ }
+ return NULL;
}
bool DecodeBitmap(const void* buffer, size_t size, SkBitmap* bm) {
« no previous file with comments | « no previous file | content/renderer/gpu/gpu_benchmarking_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698