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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 void fallbackToSoftwareOnFailedTextureAlloc() 131 void fallbackToSoftwareOnFailedTextureAlloc()
132 { 132 {
133 { 133 {
134 // No fallback case. 134 // No fallback case.
135 FakeGLES2Interface gl; 135 FakeGLES2Interface gl;
136 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); 136 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
137 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(std:: move(contextProvider), IntSize(300, 150), 0, NonOpaque, Canvas2DLayerBridge::Ena bleAcceleration, nullptr))); 137 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(std:: move(contextProvider), IntSize(300, 150), 0, NonOpaque, Canvas2DLayerBridge::Ena bleAcceleration, nullptr)));
138 EXPECT_TRUE(bridge->checkSurfaceValid()); 138 EXPECT_TRUE(bridge->checkSurfaceValid());
139 EXPECT_TRUE(bridge->isAccelerated()); 139 EXPECT_TRUE(bridge->isAccelerated());
140 RefPtr<SkImage> snapshot = bridge->newImageSnapshot(PreferAccelerati on, SnapshotReasonUnitTests); 140 sk_sp<SkImage> snapshot = bridge->newImageSnapshot(PreferAcceleratio n, SnapshotReasonUnitTests);
141 EXPECT_TRUE(bridge->isAccelerated()); 141 EXPECT_TRUE(bridge->isAccelerated());
142 EXPECT_TRUE(snapshot->isTextureBacked()); 142 EXPECT_TRUE(snapshot->isTextureBacked());
143 } 143 }
144 144
145 { 145 {
146 // Fallback case. 146 // Fallback case.
147 FakeGLES2Interface gl; 147 FakeGLES2Interface gl;
148 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); 148 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
149 GrContext* gr = contextProvider->grContext(); 149 GrContext* gr = contextProvider->grContext();
150 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(std:: move(contextProvider), IntSize(300, 150), 0, NonOpaque, Canvas2DLayerBridge::Ena bleAcceleration, nullptr))); 150 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(std:: move(contextProvider), IntSize(300, 150), 0, NonOpaque, Canvas2DLayerBridge::Ena bleAcceleration, nullptr)));
151 EXPECT_TRUE(bridge->checkSurfaceValid()); 151 EXPECT_TRUE(bridge->checkSurfaceValid());
152 EXPECT_TRUE(bridge->isAccelerated()); // We don't yet know that allo cation will fail 152 EXPECT_TRUE(bridge->isAccelerated()); // We don't yet know that allo cation will fail
153 // This will cause SkSurface_Gpu creation to fail without 153 // This will cause SkSurface_Gpu creation to fail without
154 // Canvas2DLayerBridge otherwise detecting that anything was disable d. 154 // Canvas2DLayerBridge otherwise detecting that anything was disable d.
155 gr->abandonContext(); 155 gr->abandonContext();
156 RefPtr<SkImage> snapshot = bridge->newImageSnapshot(PreferAccelerati on, SnapshotReasonUnitTests); 156 sk_sp<SkImage> snapshot = bridge->newImageSnapshot(PreferAcceleratio n, SnapshotReasonUnitTests);
157 EXPECT_FALSE(bridge->isAccelerated()); 157 EXPECT_FALSE(bridge->isAccelerated());
158 EXPECT_FALSE(snapshot->isTextureBacked()); 158 EXPECT_FALSE(snapshot->isTextureBacked());
159 } 159 }
160 } 160 }
161 161
162 void noDrawOnContextLostTest() 162 void noDrawOnContextLostTest()
163 { 163 {
164 FakeGLES2Interface gl; 164 FakeGLES2Interface gl;
165 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = wrap Unique(new FakeWebGraphicsContext3DProvider(&gl)); 165 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = wrap Unique(new FakeWebGraphicsContext3DProvider(&gl));
166 166
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 241 }
242 242
243 void accelerationHintTest() 243 void accelerationHintTest()
244 { 244 {
245 { 245 {
246 FakeGLES2Interface gl; 246 FakeGLES2Interface gl;
247 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); 247 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
248 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(std:: move(contextProvider), IntSize(300, 300), 0, NonOpaque, Canvas2DLayerBridge::Ena bleAcceleration, nullptr))); 248 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(std:: move(contextProvider), IntSize(300, 300), 0, NonOpaque, Canvas2DLayerBridge::Ena bleAcceleration, nullptr)));
249 SkPaint paint; 249 SkPaint paint;
250 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); 250 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint);
251 RefPtr<SkImage> image = bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnitTests); 251 sk_sp<SkImage> image = bridge->newImageSnapshot(PreferAcceleration, SnapshotReasonUnitTests);
252 EXPECT_TRUE(bridge->checkSurfaceValid()); 252 EXPECT_TRUE(bridge->checkSurfaceValid());
253 EXPECT_TRUE(bridge->isAccelerated()); 253 EXPECT_TRUE(bridge->isAccelerated());
254 } 254 }
255 255
256 { 256 {
257 FakeGLES2Interface gl; 257 FakeGLES2Interface gl;
258 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); 258 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = wrapUnique(new FakeWebGraphicsContext3DProvider(&gl));
259 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(std:: move(contextProvider), IntSize(300, 300), 0, NonOpaque, Canvas2DLayerBridge::Ena bleAcceleration, nullptr))); 259 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(std:: move(contextProvider), IntSize(300, 300), 0, NonOpaque, Canvas2DLayerBridge::Ena bleAcceleration, nullptr)));
260 SkPaint paint; 260 SkPaint paint;
261 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); 261 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint);
262 RefPtr<SkImage> image = bridge->newImageSnapshot(PreferNoAcceleratio n, SnapshotReasonUnitTests); 262 sk_sp<SkImage> image = bridge->newImageSnapshot(PreferNoAcceleration , SnapshotReasonUnitTests);
263 EXPECT_TRUE(bridge->checkSurfaceValid()); 263 EXPECT_TRUE(bridge->checkSurfaceValid());
264 EXPECT_FALSE(bridge->isAccelerated()); 264 EXPECT_FALSE(bridge->isAccelerated());
265 } 265 }
266 } 266 }
267 }; 267 };
268 268
269 TEST_F(Canvas2DLayerBridgeTest, FullLifecycleSingleThreaded) 269 TEST_F(Canvas2DLayerBridgeTest, FullLifecycleSingleThreaded)
270 { 270 {
271 fullLifecycleTest(); 271 fullLifecycleTest();
272 } 272 }
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) 789 EXPECT_CALL(*mockLoggerPtr, didStartHibernating())
790 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), &WaitableEvent: :signal)); 790 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), &WaitableEvent: :signal));
791 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); 791 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true);
792 hibernationStartedEvent->wait(); 792 hibernationStartedEvent->wait();
793 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); 793 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr);
794 EXPECT_FALSE(bridge->isAccelerated()); 794 EXPECT_FALSE(bridge->isAccelerated());
795 EXPECT_TRUE(bridge->isHibernating()); 795 EXPECT_TRUE(bridge->isHibernating());
796 EXPECT_TRUE(bridge->checkSurfaceValid()); 796 EXPECT_TRUE(bridge->checkSurfaceValid());
797 797
798 // Take a snapshot and verify that it is not accelerated due to hibernation 798 // Take a snapshot and verify that it is not accelerated due to hibernation
799 RefPtr<SkImage> image = bridge->newImageSnapshot(PreferAcceleration, Snapsho tReasonUnitTests); 799 sk_sp<SkImage> image = bridge->newImageSnapshot(PreferAcceleration, Snapshot ReasonUnitTests);
800 EXPECT_FALSE(image->isTextureBacked()); 800 EXPECT_FALSE(image->isTextureBacked());
801 image.clear(); 801 image.reset();
802 802
803 // Verify that taking a snapshot did not affect the state of bridge 803 // Verify that taking a snapshot did not affect the state of bridge
804 EXPECT_FALSE(bridge->isAccelerated()); 804 EXPECT_FALSE(bridge->isAccelerated());
805 EXPECT_TRUE(bridge->isHibernating()); 805 EXPECT_TRUE(bridge->isHibernating());
806 EXPECT_TRUE(bridge->checkSurfaceValid()); 806 EXPECT_TRUE(bridge->checkSurfaceValid());
807 807
808 // End hibernation normally 808 // End hibernation normally
809 std::unique_ptr<WaitableEvent> hibernationEndedEvent = wrapUnique(new Waitab leEvent()); 809 std::unique_ptr<WaitableEvent> hibernationEndedEvent = wrapUnique(new Waitab leEvent());
810 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe rnationEndedNormally)) 810 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe rnationEndedNormally))
811 .WillOnce(testing::InvokeWithoutArgs(hibernationEndedEvent.get(), &Waita bleEvent::signal)); 811 .WillOnce(testing::InvokeWithoutArgs(hibernationEndedEvent.get(), &Waita bleEvent::signal));
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; 1060 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback;
1061 EXPECT_FALSE(bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback )); 1061 EXPECT_FALSE(bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback ));
1062 EXPECT_TRUE(bridge->checkSurfaceValid()); 1062 EXPECT_TRUE(bridge->checkSurfaceValid());
1063 1063
1064 // Tear down the bridge on the thread so that 'bridge' can go out of scope 1064 // Tear down the bridge on the thread so that 'bridge' can go out of scope
1065 // without crashing due to thread checks 1065 // without crashing due to thread checks
1066 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); 1066 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge);
1067 } 1067 }
1068 1068
1069 } // namespace blink 1069 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698