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

Side by Side Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 2333713002: change SkStreams to work with sk_sp<SkData> instead of SkData* (Closed)
Patch Set: fix xpsdevice Created 4 years, 3 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
« no previous file with comments | « tests/AnnotationTest.cpp ('k') | tests/CodecPriv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 20 matching lines...) Expand all
31 canvas.drawRectCoords(0, 0, SkIntToScalar(W/2), 31 canvas.drawRectCoords(0, 0, SkIntToScalar(W/2),
32 SkIntToScalar(H/2), paint); 32 SkIntToScalar(H/2), paint);
33 paint.setColor(SK_ColorWHITE); 33 paint.setColor(SK_ColorWHITE);
34 canvas.drawRectCoords(SkIntToScalar(W/2), SkIntToScalar(H/2), 34 canvas.drawRectCoords(SkIntToScalar(W/2), SkIntToScalar(H/2),
35 SkIntToScalar(W), SkIntToScalar(H), paint); 35 SkIntToScalar(W), SkIntToScalar(H), paint);
36 } 36 }
37 37
38 /** 38 /**
39 * encode this bitmap into some data via SkImageEncoder 39 * encode this bitmap into some data via SkImageEncoder
40 */ 40 */
41 static SkData* create_data_from_bitmap(const SkBitmap& bm, 41 static sk_sp<SkData> create_data_from_bitmap(const SkBitmap& bm, SkImageEncoder: :Type type) {
42 SkImageEncoder::Type type) {
43 SkDynamicMemoryWStream stream; 42 SkDynamicMemoryWStream stream;
44 if (SkImageEncoder::EncodeStream(&stream, bm, type, 100)) { 43 if (SkImageEncoder::EncodeStream(&stream, bm, type, 100)) {
45 return stream.copyToData(); 44 return stream.detachAsData();
46 } 45 }
47 return nullptr; 46 return nullptr;
48 } 47 }
49 48
50 //////////////////////////////////////////////////////////////////////////////// 49 ////////////////////////////////////////////////////////////////////////////////
51 50
52 static void compare_bitmaps(skiatest::Reporter* reporter, 51 static void compare_bitmaps(skiatest::Reporter* reporter,
53 const SkBitmap& b1, const SkBitmap& b2, 52 const SkBitmap& b1, const SkBitmap& b2,
54 bool pixelPerfect = true) { 53 bool pixelPerfect = true) {
55 REPORTER_ASSERT(reporter, b1.empty() == b2.empty()); 54 REPORTER_ASSERT(reporter, b1.empty() == b2.empty());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 if (original.empty() || original.isNull()) { 99 if (original.empty() || original.isNull()) {
101 return; 100 return;
102 } 101 }
103 static const SkImageEncoder::Type types[] = { 102 static const SkImageEncoder::Type types[] = {
104 SkImageEncoder::kPNG_Type, 103 SkImageEncoder::kPNG_Type,
105 SkImageEncoder::kJPEG_Type, 104 SkImageEncoder::kJPEG_Type,
106 SkImageEncoder::kWEBP_Type 105 SkImageEncoder::kWEBP_Type
107 }; 106 };
108 for (size_t i = 0; i < SK_ARRAY_COUNT(types); i++) { 107 for (size_t i = 0; i < SK_ARRAY_COUNT(types); i++) {
109 SkImageEncoder::Type type = types[i]; 108 SkImageEncoder::Type type = types[i];
110 sk_sp<SkData> encoded(create_data_from_bitmap(original, type)); 109 sk_sp<SkData> encoded = create_data_from_bitmap(original, type);
111 REPORTER_ASSERT(reporter, encoded.get() != nullptr); 110 REPORTER_ASSERT(reporter, encoded.get() != nullptr);
112 if (nullptr == encoded.get()) { 111 if (nullptr == encoded.get()) {
113 continue; 112 continue;
114 } 113 }
115 SkBitmap lazy; 114 SkBitmap lazy;
116 bool installSuccess = install(encoded.get(), &lazy); 115 bool installSuccess = install(encoded.get(), &lazy);
117 REPORTER_ASSERT(reporter, installSuccess); 116 REPORTER_ASSERT(reporter, installSuccess);
118 if (!installSuccess) { 117 if (!installSuccess) {
119 continue; 118 continue;
120 } 119 }
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 if (TestImageGenerator::kSucceedGetPixels_TestType == test) { 338 if (TestImageGenerator::kSucceedGetPixels_TestType == test) {
340 REPORTER_ASSERT( 339 REPORTER_ASSERT(
341 r, TestImageGenerator::Color() == bitmap.getColor(0, 0)); 340 r, TestImageGenerator::Color() == bitmap.getColor(0, 0));
342 } 341 }
343 else { 342 else {
344 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0, 0)); 343 REPORTER_ASSERT(r, kDefaultColor == bitmap.getColor(0, 0));
345 } 344 }
346 } 345 }
347 } 346 }
348 } 347 }
OLDNEW
« no previous file with comments | « tests/AnnotationTest.cpp ('k') | tests/CodecPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698