aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-21 20:31:23 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-21 20:31:23 +0000
commit1b1bcc3ceac9b4adbb4de68429903a5f721ffe62 (patch)
tree7084ea3c22ee61a406f9d1a55936c56ffb565236 /tests
parent2522ac64485dbff51dd86c870506c24f43f741e6 (diff)
New API for encoding bitmaps during serialization.
This change gives more flexibility to the implementation of EncodeBitmap to prefer calling refEncodedData, doing its own encode, or even doing both and making a decision about which to use. The new function signature also allows the implementation to tell the ordered write buffer whether to store the pixel offset, in the case where the encoded bitmap represents the larger bitmap, or to ignore the pixel offset, in the case where the implementation only encoded the subset that is used. Requires changes to chromium to use the new function signature. (https://codereview.chromium.org/15496006/) SkPicture: New API for EncodeBitmap. SkOrderedReadBuffer: Ifdef'd out addition of reading the offset. SkOrderedWriteBuffer: Never call refEncodedData. Allow the user to call that from their EncodeBitmap function, if desired. This addresses https://code.google.com/p/skia/issues/detail?id=1239 Add in ifdef'd out code to record the offset. PictureTest and PictureRenderer: Implement the new definition of EncodeBitmap. Also update the name of the function to meet coding style guidelines. BUG=https://code.google.com/p/skia/issues/detail?id=1239 R=reed@google.com Review URL: https://codereview.chromium.org/15489004 git-svn-id: http://skia.googlecode.com/svn/trunk@9226 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/PictureTest.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 20226e7d56..23ff6893c0 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -359,8 +359,9 @@ private:
#include "SkImageEncoder.h"
-static bool PNGEncodeBitmapToStream(SkWStream* wStream, const SkBitmap& bm) {
- return SkImageEncoder::EncodeStream(wStream, bm, SkImageEncoder::kPNG_Type, 100);
+static SkData* encode_bitmap_to_data(size_t* offset, const SkBitmap& bm) {
+ *offset = 0;
+ return SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, 100);
}
static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) {
@@ -368,7 +369,7 @@ static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) {
SkCanvas* canvas = picture.beginRecording(bitmap.width(), bitmap.height());
canvas->drawBitmap(bitmap, 0, 0);
SkDynamicMemoryWStream wStream;
- picture.serialize(&wStream, &PNGEncodeBitmapToStream);
+ picture.serialize(&wStream, &encode_bitmap_to_data);
return wStream.copyToData();
}