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

Side by Side Diff: tests/PictureTest.cpp

Issue 295243006: hide discardable factory from public imagegenerator api (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 6 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 7
8 #include "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 SkBitmap original; 1106 SkBitmap original;
1107 make_bm(&original, 100, 100, SK_ColorBLUE, true); 1107 make_bm(&original, 100, 100, SK_ColorBLUE, true);
1108 SkDynamicMemoryWStream wStream; 1108 SkDynamicMemoryWStream wStream;
1109 if (!SkImageEncoder::EncodeStream(&wStream, original, SkImageEncoder::kPNG_T ype, 100)) { 1109 if (!SkImageEncoder::EncodeStream(&wStream, original, SkImageEncoder::kPNG_T ype, 100)) {
1110 return; 1110 return;
1111 } 1111 }
1112 SkAutoDataUnref data(wStream.copyToData()); 1112 SkAutoDataUnref data(wStream.copyToData());
1113 1113
1114 SkBitmap bm; 1114 SkBitmap bm;
1115 bool installSuccess = SkInstallDiscardablePixelRef( 1115 bool installSuccess = SkInstallDiscardablePixelRef(
1116 SkDecodingImageGenerator::Create(data, SkDecodingImageGenerator::Option s()), &bm, NULL); 1116 SkDecodingImageGenerator::Create(data, SkDecodingImageGenerator::Option s()), &bm);
1117 REPORTER_ASSERT(reporter, installSuccess); 1117 REPORTER_ASSERT(reporter, installSuccess);
1118 1118
1119 // Write both bitmaps to pictures, and ensure that the resulting data stream s are the same. 1119 // Write both bitmaps to pictures, and ensure that the resulting data stream s are the same.
1120 // Flattening original will follow the old path of performing an encode, whi le flattening bm 1120 // Flattening original will follow the old path of performing an encode, whi le flattening bm
1121 // will use the already encoded data. 1121 // will use the already encoded data.
1122 SkAutoDataUnref picture1(serialized_picture_from_bitmap(original)); 1122 SkAutoDataUnref picture1(serialized_picture_from_bitmap(original));
1123 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); 1123 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm));
1124 REPORTER_ASSERT(reporter, picture1->equals(picture2)); 1124 REPORTER_ASSERT(reporter, picture1->equals(picture2));
1125 // Now test that a parse error was generated when trying to create a new SkP icture without 1125 // Now test that a parse error was generated when trying to create a new SkP icture without
1126 // providing a function to decode the bitmap. 1126 // providing a function to decode the bitmap.
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 1500 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
1501 } 1501 }
1502 1502
1503 DEF_TEST(Canvas_EmptyBitmap, r) { 1503 DEF_TEST(Canvas_EmptyBitmap, r) {
1504 SkBitmap dst; 1504 SkBitmap dst;
1505 dst.allocN32Pixels(10, 10); 1505 dst.allocN32Pixels(10, 10);
1506 SkCanvas canvas(dst); 1506 SkCanvas canvas(dst);
1507 1507
1508 test_draw_bitmaps(&canvas); 1508 test_draw_bitmaps(&canvas);
1509 } 1509 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698