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

Side by Side Diff: tests/ImageGeneratorTest.cpp

Issue 2206633004: Move off SK_SUPPORT_LEGACY_DATA_FACTORIES. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Gotta catch 'em all. 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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "SkData.h" 8 #include "SkData.h"
9 #include "SkGraphics.h" 9 #include "SkGraphics.h"
10 #include "SkImageGenerator.h" 10 #include "SkImageGenerator.h"
11 #include "Test.h" 11 #include "Test.h"
12 12
13 static bool gMyFactoryWasCalled; 13 static bool gMyFactoryWasCalled;
14 14
15 static SkImageGenerator* my_factory(SkData*) { 15 static SkImageGenerator* my_factory(SkData*) {
16 gMyFactoryWasCalled = true; 16 gMyFactoryWasCalled = true;
17 return nullptr; 17 return nullptr;
18 } 18 }
19 19
20 static void test_imagegenerator_factory(skiatest::Reporter* reporter) { 20 static void test_imagegenerator_factory(skiatest::Reporter* reporter) {
21 // just need a non-empty data to test things 21 // just need a non-empty data to test things
22 SkAutoTUnref<SkData> data(SkData::NewWithCString("test_imagegenerator_factor y")); 22 sk_sp<SkData> data(SkData::MakeWithCString("test_imagegenerator_factory"));
23 23
24 gMyFactoryWasCalled = false; 24 gMyFactoryWasCalled = false;
25 25
26 SkImageGenerator* gen; 26 SkImageGenerator* gen;
27 REPORTER_ASSERT(reporter, !gMyFactoryWasCalled); 27 REPORTER_ASSERT(reporter, !gMyFactoryWasCalled);
28 28
29 gen = SkImageGenerator::NewFromEncoded(data); 29 gen = SkImageGenerator::NewFromEncoded(data.get());
30 REPORTER_ASSERT(reporter, nullptr == gen); 30 REPORTER_ASSERT(reporter, nullptr == gen);
31 REPORTER_ASSERT(reporter, !gMyFactoryWasCalled); 31 REPORTER_ASSERT(reporter, !gMyFactoryWasCalled);
32 32
33 // Test is racy, in that it hopes no other thread is changing this global... 33 // Test is racy, in that it hopes no other thread is changing this global...
34 SkGraphics::ImageGeneratorFromEncodedFactory prev = 34 SkGraphics::ImageGeneratorFromEncodedFactory prev =
35 SkGraphics::SetImageGeneratorFromEncodedFact ory(my_factory); 35 SkGraphics::SetImageGeneratorFromEncodedFact ory(my_factory);
36 gen = SkImageGenerator::NewFromEncoded(data); 36 gen = SkImageGenerator::NewFromEncoded(data.get());
37 REPORTER_ASSERT(reporter, nullptr == gen); 37 REPORTER_ASSERT(reporter, nullptr == gen);
38 REPORTER_ASSERT(reporter, gMyFactoryWasCalled); 38 REPORTER_ASSERT(reporter, gMyFactoryWasCalled);
39 SkGraphics::SetImageGeneratorFromEncodedFactory(prev); 39 SkGraphics::SetImageGeneratorFromEncodedFactory(prev);
40 } 40 }
41 41
42 class MyImageGenerator : public SkImageGenerator { 42 class MyImageGenerator : public SkImageGenerator {
43 public: 43 public:
44 MyImageGenerator() : SkImageGenerator(SkImageInfo::MakeN32Premul(0, 0)) {} 44 MyImageGenerator() : SkImageGenerator(SkImageInfo::MakeN32Premul(0, 0)) {}
45 }; 45 };
46 46
(...skipping 17 matching lines...) Expand all
64 sizeInfo.fWidthBytes[SkYUVSizeInfo::kV] = 250; 64 sizeInfo.fWidthBytes[SkYUVSizeInfo::kV] = 250;
65 int dummy; 65 int dummy;
66 planes[SkYUVSizeInfo::kY] = planes[SkYUVSizeInfo::kU] = planes[SkYUVSizeInfo ::kV] = &dummy; 66 planes[SkYUVSizeInfo::kY] = planes[SkYUVSizeInfo::kU] = planes[SkYUVSizeInfo ::kV] = &dummy;
67 ig.getYUV8Planes(sizeInfo, planes); 67 ig.getYUV8Planes(sizeInfo, planes);
68 68
69 // Suppressed due to https://code.google.com/p/skia/issues/detail?id=4339 69 // Suppressed due to https://code.google.com/p/skia/issues/detail?id=4339
70 if (false) { 70 if (false) {
71 test_imagegenerator_factory(reporter); 71 test_imagegenerator_factory(reporter);
72 } 72 }
73 } 73 }
OLDNEW
« include/core/SkData.h ('K') | « tests/DataRefTest.cpp ('k') | tests/ImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698