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

Side by Side Diff: tests/ImageTest.cpp

Issue 2218223002: update Image_MakeFromRasterBitmap to check uniqueIDs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 <functional> 8 #include <functional>
9 #include <initializer_list> 9 #include <initializer_list>
10 #include <vector> 10 #include <vector>
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 }; 204 };
205 for (auto rec : recs) { 205 for (auto rec : recs) {
206 SkPixmap pm; 206 SkPixmap pm;
207 SkBitmap bm; 207 SkBitmap bm;
208 bm.allocN32Pixels(100, 100); 208 bm.allocN32Pixels(100, 100);
209 209
210 auto img = SkMakeImageFromRasterBitmap(bm, rec.fCPM); 210 auto img = SkMakeImageFromRasterBitmap(bm, rec.fCPM);
211 REPORTER_ASSERT(reporter, img->peekPixels(&pm)); 211 REPORTER_ASSERT(reporter, img->peekPixels(&pm));
212 const bool sameMutable = pm.addr32(0, 0) == bm.getAddr32(0, 0); 212 const bool sameMutable = pm.addr32(0, 0) == bm.getAddr32(0, 0);
213 REPORTER_ASSERT(reporter, rec.fExpectSameAsMutable == sameMutable); 213 REPORTER_ASSERT(reporter, rec.fExpectSameAsMutable == sameMutable);
214 REPORTER_ASSERT(reporter, (bm.getGenerationID() == img->uniqueID()) == s ameMutable);
214 215
215 bm.notifyPixelsChanged(); // force a new generation ID 216 bm.notifyPixelsChanged(); // force a new generation ID
216 217
217 bm.setImmutable(); 218 bm.setImmutable();
218 img = SkMakeImageFromRasterBitmap(bm, rec.fCPM); 219 img = SkMakeImageFromRasterBitmap(bm, rec.fCPM);
219 REPORTER_ASSERT(reporter, img->peekPixels(&pm)); 220 REPORTER_ASSERT(reporter, img->peekPixels(&pm));
220 const bool sameImmutable = pm.addr32(0, 0) == bm.getAddr32(0, 0); 221 const bool sameImmutable = pm.addr32(0, 0) == bm.getAddr32(0, 0);
221 REPORTER_ASSERT(reporter, rec.fExpectSameAsImmutable == sameImmutable); 222 REPORTER_ASSERT(reporter, rec.fExpectSameAsImmutable == sameImmutable);
223 REPORTER_ASSERT(reporter, (bm.getGenerationID() == img->uniqueID()) == s ameImmutable);
222 } 224 }
223 } 225 }
224 226
225 namespace { 227 namespace {
226 228
227 const char* kSerializedData = "serialized"; 229 const char* kSerializedData = "serialized";
228 230
229 class MockSerializer : public SkPixelSerializer { 231 class MockSerializer : public SkPixelSerializer {
230 public: 232 public:
231 MockSerializer(sk_sp<SkData> (*func)()) : fFunc(func), fDidEncode(false) { } 233 MockSerializer(sk_sp<SkData> (*func)()) : fFunc(func), fDidEncode(false) { }
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 SkBitmap bm1; 1017 SkBitmap bm1;
1016 bm1.allocPixels(SkImageInfo::MakeN32(256, 256, kUnpremul_SkAlphaType)); 1018 bm1.allocPixels(SkImageInfo::MakeN32(256, 256, kUnpremul_SkAlphaType));
1017 bm0.readPixels(bm1.info(), bm1.getPixels(), bm1.rowBytes(), 0, 0); 1019 bm0.readPixels(bm1.info(), bm1.getPixels(), bm1.rowBytes(), 0, 0);
1018 1020
1019 SkBitmap bm2; 1021 SkBitmap bm2;
1020 bm2.allocPixels(SkImageInfo::MakeN32(256, 256, kPremul_SkAlphaType)); 1022 bm2.allocPixels(SkImageInfo::MakeN32(256, 256, kPremul_SkAlphaType));
1021 bm1.readPixels(bm2.info(), bm2.getPixels(), bm2.rowBytes(), 0, 0); 1023 bm1.readPixels(bm2.info(), bm2.getPixels(), bm2.rowBytes(), 0, 0);
1022 1024
1023 REPORTER_ASSERT(reporter, equal(bm0, bm2)); 1025 REPORTER_ASSERT(reporter, equal(bm0, bm2));
1024 } 1026 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698