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

Side by Side Diff: tests/PictureTest.cpp

Issue 834633006: add ImageGenerator::NewFromData to porting layer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add helper for SkInstallDiscardablePixelRef(SkData*, ...) Created 5 years, 11 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
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 "SkBBoxHierarchy.h" 8 #include "SkBBoxHierarchy.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkColorMatrixFilter.h" 11 #include "SkColorMatrixFilter.h"
12 #include "SkColorPriv.h" 12 #include "SkColorPriv.h"
13 #include "SkDashPathEffect.h" 13 #include "SkDashPathEffect.h"
14 #include "SkData.h" 14 #include "SkData.h"
15 #include "SkDecodingImageGenerator.h" 15 #include "SkImageGenerator.h"
16 #include "SkError.h" 16 #include "SkError.h"
17 #include "SkImageEncoder.h" 17 #include "SkImageEncoder.h"
18 #include "SkImageGenerator.h" 18 #include "SkImageGenerator.h"
19 #include "SkLayerInfo.h" 19 #include "SkLayerInfo.h"
20 #include "SkPaint.h" 20 #include "SkPaint.h"
21 #include "SkPicture.h" 21 #include "SkPicture.h"
22 #include "SkPictureRecorder.h" 22 #include "SkPictureRecorder.h"
23 #include "SkPictureUtils.h" 23 #include "SkPictureUtils.h"
24 #include "SkPixelRef.h" 24 #include "SkPixelRef.h"
25 #include "SkPixelSerializer.h" 25 #include "SkPixelSerializer.h"
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 // Create a bitmap that will be encoded. 1488 // Create a bitmap that will be encoded.
1489 SkBitmap original; 1489 SkBitmap original;
1490 make_bm(&original, 100, 100, SK_ColorBLUE, true); 1490 make_bm(&original, 100, 100, SK_ColorBLUE, true);
1491 SkDynamicMemoryWStream wStream; 1491 SkDynamicMemoryWStream wStream;
1492 if (!SkImageEncoder::EncodeStream(&wStream, original, SkImageEncoder::kPNG_T ype, 100)) { 1492 if (!SkImageEncoder::EncodeStream(&wStream, original, SkImageEncoder::kPNG_T ype, 100)) {
1493 return; 1493 return;
1494 } 1494 }
1495 SkAutoDataUnref data(wStream.copyToData()); 1495 SkAutoDataUnref data(wStream.copyToData());
1496 1496
1497 SkBitmap bm; 1497 SkBitmap bm;
1498 bool installSuccess = SkInstallDiscardablePixelRef( 1498 bool installSuccess = SkInstallDiscardablePixelRef(data, &bm);
1499 SkDecodingImageGenerator::Create(data, SkDecodingImageGenerator::Option s()), &bm);
1500 REPORTER_ASSERT(reporter, installSuccess); 1499 REPORTER_ASSERT(reporter, installSuccess);
1501 1500
1502 // Write both bitmaps to pictures, and ensure that the resulting data stream s are the same. 1501 // Write both bitmaps to pictures, and ensure that the resulting data stream s are the same.
1503 // Flattening original will follow the old path of performing an encode, whi le flattening bm 1502 // Flattening original will follow the old path of performing an encode, whi le flattening bm
1504 // will use the already encoded data. 1503 // will use the already encoded data.
1505 SkAutoDataUnref picture1(serialized_picture_from_bitmap(original)); 1504 SkAutoDataUnref picture1(serialized_picture_from_bitmap(original));
1506 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm)); 1505 SkAutoDataUnref picture2(serialized_picture_from_bitmap(bm));
1507 REPORTER_ASSERT(reporter, picture1->equals(picture2)); 1506 REPORTER_ASSERT(reporter, picture1->equals(picture2));
1508 // Now test that a parse error was generated when trying to create a new SkP icture without 1507 // Now test that a parse error was generated when trying to create a new SkP icture without
1509 // providing a function to decode the bitmap. 1508 // providing a function to decode the bitmap.
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 1927
1929 // The picture shares the immutable pixels but copies the mutable ones. 1928 // The picture shares the immutable pixels but copies the mutable ones.
1930 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1929 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1931 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); 1930 REPORTER_ASSERT(r, !immut.pixelRef()->unique());
1932 1931
1933 // When the picture goes away, it's just our bitmaps holding the refs. 1932 // When the picture goes away, it's just our bitmaps holding the refs.
1934 pic.reset(NULL); 1933 pic.reset(NULL);
1935 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1934 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1936 REPORTER_ASSERT(r, immut.pixelRef()->unique()); 1935 REPORTER_ASSERT(r, immut.pixelRef()->unique());
1937 } 1936 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698