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

Side by Side Diff: tests/PictureTest.cpp

Issue 15489004: New API for encoding bitmaps during serialization. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix ifdef'd out code 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "Test.h" 7 #include "Test.h"
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 fData->ref(); 352 fData->ref();
353 return fData; 353 return fData;
354 } 354 }
355 355
356 private: 356 private:
357 SkData* fData; 357 SkData* fData;
358 }; 358 };
359 359
360 #include "SkImageEncoder.h" 360 #include "SkImageEncoder.h"
361 361
362 static bool PNGEncodeBitmapToStream(SkWStream* wStream, const SkBitmap& bm) { 362 static SkData* encode_bitmap_to_data(size_t* offset, const SkBitmap& bm) {
363 return SkImageEncoder::EncodeStream(wStream, bm, SkImageEncoder::kPNG_Type, 100); 363 *offset = 0;
364 return SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, 100);
364 } 365 }
365 366
366 static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) { 367 static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) {
367 SkPicture picture; 368 SkPicture picture;
368 SkCanvas* canvas = picture.beginRecording(bitmap.width(), bitmap.height()); 369 SkCanvas* canvas = picture.beginRecording(bitmap.width(), bitmap.height());
369 canvas->drawBitmap(bitmap, 0, 0); 370 canvas->drawBitmap(bitmap, 0, 0);
370 SkDynamicMemoryWStream wStream; 371 SkDynamicMemoryWStream wStream;
371 picture.serialize(&wStream, &PNGEncodeBitmapToStream); 372 picture.serialize(&wStream, &encode_bitmap_to_data);
372 return wStream.copyToData(); 373 return wStream.copyToData();
373 } 374 }
374 375
375 struct ErrorContext { 376 struct ErrorContext {
376 int fErrors; 377 int fErrors;
377 skiatest::Reporter* fReporter; 378 skiatest::Reporter* fReporter;
378 }; 379 };
379 380
380 static void assert_one_parse_error_cb(SkError error, void* context) { 381 static void assert_one_parse_error_cb(SkError error, void* context) {
381 ErrorContext* errorContext = static_cast<ErrorContext*>(context); 382 ErrorContext* errorContext = static_cast<ErrorContext*>(context);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 #endif 558 #endif
558 test_peephole(); 559 test_peephole();
559 test_gatherpixelrefs(reporter); 560 test_gatherpixelrefs(reporter);
560 test_bitmap_with_encoded_data(reporter); 561 test_bitmap_with_encoded_data(reporter);
561 test_clone_empty(reporter); 562 test_clone_empty(reporter);
562 test_clip_bound_opt(reporter); 563 test_clip_bound_opt(reporter);
563 } 564 }
564 565
565 #include "TestClassDef.h" 566 #include "TestClassDef.h"
566 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture) 567 DEFINE_TESTCLASS("Pictures", PictureTestClass, TestPicture)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698