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

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: Respond to comment. 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
Index: cc/resources/picture.cc
diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc
index 37946055ae16d6dcfdaa1a09d452a632d17a1ceb..c840655885b64b705ef9275b3d96d25b62f659af 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') | content/renderer/gpu/gpu_benchmarking_extension.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698