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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImageLayerChromiumTest.cpp

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Rebasing... 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override 47 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override
48 { 48 {
49 return m_image->isOpaque(); 49 return m_image->isOpaque();
50 } 50 }
51 51
52 IntSize size() const override 52 IntSize size() const override
53 { 53 {
54 return m_size; 54 return m_size;
55 } 55 }
56 56
57 PassRefPtr<SkImage> imageForCurrentFrame() override 57 sk_sp<SkImage> imageForCurrentFrame() override
58 { 58 {
59 return m_image; 59 return m_image;
60 } 60 }
61 61
62 void destroyDecodedData() override 62 void destroyDecodedData() override
63 { 63 {
64 // Image pure virtual stub. 64 // Image pure virtual stub.
65 } 65 }
66 66
67 void draw(SkCanvas*, const SkPaint&, const FloatRect&, const FloatRect&, Res pectImageOrientationEnum, ImageClampingMode) override 67 void draw(SkCanvas*, const SkPaint&, const FloatRect&, const FloatRect&, Res pectImageOrientationEnum, ImageClampingMode) override
68 { 68 {
69 // Image pure virtual stub. 69 // Image pure virtual stub.
70 } 70 }
71 71
72 private: 72 private:
73 TestImage(IntSize size, bool opaque) 73 TestImage(IntSize size, bool opaque)
74 : Image(0) 74 : Image(0)
75 , m_size(size) 75 , m_size(size)
76 { 76 {
77 sk_sp<SkSurface> surface = createSkSurface(size, opaque); 77 sk_sp<SkSurface> surface = createSkSurface(size, opaque);
78 if (!surface) 78 if (!surface)
79 return; 79 return;
80 80
81 surface->getCanvas()->clear(SK_ColorTRANSPARENT); 81 surface->getCanvas()->clear(SK_ColorTRANSPARENT);
82 m_image = fromSkSp(surface->makeImageSnapshot()); 82 m_image = surface->makeImageSnapshot();
83 } 83 }
84 84
85 static sk_sp<SkSurface> createSkSurface(IntSize size, bool opaque) 85 static sk_sp<SkSurface> createSkSurface(IntSize size, bool opaque)
86 { 86 {
87 return SkSurface::MakeRaster(SkImageInfo::MakeN32(size.width(), size.hei ght(), opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType)); 87 return SkSurface::MakeRaster(SkImageInfo::MakeN32(size.width(), size.hei ght(), opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType));
88 } 88 }
89 89
90 IntSize m_size; 90 IntSize m_size;
91 RefPtr<SkImage> m_image; 91 sk_sp<SkImage> m_image;
92 }; 92 };
93 93
94 } // anonymous namespace 94 } // anonymous namespace
95 95
96 TEST(ImageLayerChromiumTest, imageLayerContentReset) 96 TEST(ImageLayerChromiumTest, imageLayerContentReset)
97 { 97 {
98 FakeGraphicsLayerClient client; 98 FakeGraphicsLayerClient client;
99 std::unique_ptr<FakeGraphicsLayer> graphicsLayer = wrapUnique(new FakeGraphi csLayer(&client)); 99 std::unique_ptr<FakeGraphicsLayer> graphicsLayer = wrapUnique(new FakeGraphi csLayer(&client));
100 ASSERT_TRUE(graphicsLayer.get()); 100 ASSERT_TRUE(graphicsLayer.get());
101 101
(...skipping 28 matching lines...) Expand all
130 ASSERT_FALSE(graphicsLayer->contentsLayer()); 130 ASSERT_FALSE(graphicsLayer->contentsLayer());
131 131
132 graphicsLayer->setContentsToImage(opaqueImage.get()); 132 graphicsLayer->setContentsToImage(opaqueImage.get());
133 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); 133 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque());
134 134
135 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); 135 graphicsLayer->setContentsToImage(nonOpaqueImage.get());
136 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); 136 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque());
137 } 137 }
138 138
139 } // namespace blink 139 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698