| OLD | NEW |
| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y |
| 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N |
| 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "platform/graphics/Canvas2DLayerBridge.h" | 25 #include "platform/graphics/Canvas2DLayerBridge.h" |
| 26 | 26 |
| 27 #include "SkSurface.h" | 27 #include "cc/resources/single_release_callback.h" |
| 28 #include "cc/resources/texture_mailbox.h" |
| 28 #include "gpu/command_buffer/client/gles2_interface.h" | 29 #include "gpu/command_buffer/client/gles2_interface.h" |
| 29 #include "gpu/command_buffer/common/capabilities.h" | 30 #include "gpu/command_buffer/common/capabilities.h" |
| 30 #include "platform/CrossThreadFunctional.h" | 31 #include "platform/CrossThreadFunctional.h" |
| 31 #include "platform/WaitableEvent.h" | 32 #include "platform/WaitableEvent.h" |
| 32 #include "platform/graphics/ImageBuffer.h" | 33 #include "platform/graphics/ImageBuffer.h" |
| 33 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 34 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 34 #include "platform/graphics/test/FakeGLES2Interface.h" | 35 #include "platform/graphics/test/FakeGLES2Interface.h" |
| 35 #include "platform/graphics/test/FakeWebGraphicsContext3DProvider.h" | 36 #include "platform/graphics/test/FakeWebGraphicsContext3DProvider.h" |
| 36 #include "public/platform/Platform.h" | 37 #include "public/platform/Platform.h" |
| 37 #include "public/platform/WebExternalBitmap.h" | 38 #include "public/platform/WebExternalBitmap.h" |
| 38 #include "public/platform/WebScheduler.h" | 39 #include "public/platform/WebScheduler.h" |
| 39 #include "public/platform/WebTaskRunner.h" | 40 #include "public/platform/WebTaskRunner.h" |
| 40 #include "public/platform/WebThread.h" | 41 #include "public/platform/WebThread.h" |
| 41 #include "public/platform/WebTraceLocation.h" | 42 #include "public/platform/WebTraceLocation.h" |
| 42 #include "public/platform/functional/WebFunction.h" | 43 #include "public/platform/functional/WebFunction.h" |
| 43 #include "skia/ext/texture_handle.h" | 44 #include "skia/ext/texture_handle.h" |
| 44 #include "testing/gmock/include/gmock/gmock.h" | 45 #include "testing/gmock/include/gmock/gmock.h" |
| 45 #include "testing/gtest/include/gtest/gtest.h" | 46 #include "testing/gtest/include/gtest/gtest.h" |
| 46 #include "third_party/skia/include/core/SkCanvas.h" | 47 #include "third_party/skia/include/core/SkCanvas.h" |
| 48 #include "third_party/skia/include/core/SkSurface.h" |
| 47 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" | 49 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" |
| 48 #include "wtf/PtrUtil.h" | 50 #include "wtf/PtrUtil.h" |
| 49 #include "wtf/RefPtr.h" | 51 #include "wtf/RefPtr.h" |
| 52 |
| 50 #include <memory> | 53 #include <memory> |
| 51 | 54 |
| 52 using testing::AnyNumber; | 55 using testing::AnyNumber; |
| 53 using testing::AtLeast; | 56 using testing::AtLeast; |
| 54 using testing::InSequence; | 57 using testing::InSequence; |
| 55 using testing::Return; | 58 using testing::Return; |
| 56 using testing::Test; | 59 using testing::Test; |
| 57 using testing::_; | 60 using testing::_; |
| 58 | 61 |
| 59 namespace blink { | 62 namespace blink { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 85 m_layerBridge = layerBridge; | 88 m_layerBridge = layerBridge; |
| 86 } | 89 } |
| 87 | 90 |
| 88 Canvas2DLayerBridge* operator->() { return m_layerBridge.get(); } | 91 Canvas2DLayerBridge* operator->() { return m_layerBridge.get(); } |
| 89 Canvas2DLayerBridge* get() { return m_layerBridge.get(); } | 92 Canvas2DLayerBridge* get() { return m_layerBridge.get(); } |
| 90 | 93 |
| 91 private: | 94 private: |
| 92 RefPtr<Canvas2DLayerBridge> m_layerBridge; | 95 RefPtr<Canvas2DLayerBridge> m_layerBridge; |
| 93 }; | 96 }; |
| 94 | 97 |
| 95 class NullWebExternalBitmap : public WebExternalBitmap { | |
| 96 public: | |
| 97 WebSize size() override | |
| 98 { | |
| 99 return WebSize(); | |
| 100 } | |
| 101 | |
| 102 void setSize(WebSize) override | |
| 103 { | |
| 104 } | |
| 105 | |
| 106 uint8_t* pixels() override | |
| 107 { | |
| 108 return nullptr; | |
| 109 } | |
| 110 }; | |
| 111 | |
| 112 } // anonymous namespace | 98 } // anonymous namespace |
| 113 | 99 |
| 114 class Canvas2DLayerBridgeTest : public Test { | 100 class Canvas2DLayerBridgeTest : public Test { |
| 115 public: | 101 public: |
| 116 PassRefPtr<Canvas2DLayerBridge> makeBridge(std::unique_ptr<FakeWebGraphicsCo
ntext3DProvider> provider, const IntSize& size, Canvas2DLayerBridge::Acceleratio
nMode accelerationMode) | 102 PassRefPtr<Canvas2DLayerBridge> makeBridge(std::unique_ptr<FakeWebGraphicsCo
ntext3DProvider> provider, const IntSize& size, Canvas2DLayerBridge::Acceleratio
nMode accelerationMode) |
| 117 { | 103 { |
| 118 return adoptRef(new Canvas2DLayerBridge(std::move(provider), size, 0, No
nOpaque, accelerationMode)); | 104 return adoptRef(new Canvas2DLayerBridge(std::move(provider), size, 0, No
nOpaque, accelerationMode)); |
| 119 } | 105 } |
| 120 | 106 |
| 121 protected: | 107 protected: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); | 175 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); |
| 190 EXPECT_EQ(genID, bridge->getOrCreateSurface()->generationID()); | 176 EXPECT_EQ(genID, bridge->getOrCreateSurface()->generationID()); |
| 191 // This results in the internal surface being torn down in response to t
he context loss. | 177 // This results in the internal surface being torn down in response to t
he context loss. |
| 192 EXPECT_FALSE(bridge->checkSurfaceValid()); | 178 EXPECT_FALSE(bridge->checkSurfaceValid()); |
| 193 EXPECT_EQ(nullptr, bridge->getOrCreateSurface()); | 179 EXPECT_EQ(nullptr, bridge->getOrCreateSurface()); |
| 194 // The following passes by not crashing | 180 // The following passes by not crashing |
| 195 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); | 181 bridge->canvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), paint); |
| 196 bridge->flush(); | 182 bridge->flush(); |
| 197 } | 183 } |
| 198 | 184 |
| 199 void prepareMailboxWithBitmapTest() | 185 void prepareMailboxSoftwareTest() |
| 200 { | 186 { |
| 201 FakeGLES2Interface gl; | 187 FakeGLES2Interface gl; |
| 202 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = wrap
Unique(new FakeWebGraphicsContext3DProvider(&gl)); | 188 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider = wrap
Unique(new FakeWebGraphicsContext3DProvider(&gl)); |
| 203 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(std::move
(contextProvider), IntSize(300, 150), 0, NonOpaque, Canvas2DLayerBridge::ForceAc
celerationForTesting))); | 189 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(std::move
(contextProvider), IntSize(300, 150), 0, NonOpaque, Canvas2DLayerBridge::ForceAc
celerationForTesting))); |
| 204 bridge->m_lastImageId = 1; | |
| 205 | 190 |
| 206 NullWebExternalBitmap bitmap; | 191 cc::TextureMailbox textureMailbox; |
| 207 bridge->prepareMailbox(0, &bitmap); | 192 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; |
| 208 EXPECT_EQ(0u, bridge->m_lastImageId); | 193 bool useSharedMemory = true; |
| 194 EXPECT_FALSE(bridge->PrepareTextureMailbox(&textureMailbox, &releaseCall
back, useSharedMemory)); |
| 209 } | 195 } |
| 210 | 196 |
| 211 void prepareMailboxAndLoseResourceTest() | 197 void prepareMailboxAndLoseResourceTest() |
| 212 { | 198 { |
| 213 bool lostResource = true; | |
| 214 | |
| 215 // Prepare a mailbox, then report the resource as lost. | 199 // Prepare a mailbox, then report the resource as lost. |
| 216 // This test passes by not crashing and not triggering assertions. | 200 // This test passes by not crashing and not triggering assertions. |
| 217 { | 201 { |
| 218 FakeGLES2Interface gl; | 202 FakeGLES2Interface gl; |
| 219 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); | 203 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); |
| 220 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(std::
move(contextProvider), IntSize(300, 150), 0, NonOpaque, Canvas2DLayerBridge::For
ceAccelerationForTesting))); | 204 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(std::
move(contextProvider), IntSize(300, 150), 0, NonOpaque, Canvas2DLayerBridge::For
ceAccelerationForTesting))); |
| 221 WebExternalTextureMailbox mailbox; | 205 |
| 222 bridge->prepareMailbox(&mailbox, 0); | 206 cc::TextureMailbox textureMailbox; |
| 223 bridge->mailboxReleased(mailbox, lostResource); | 207 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; |
| 208 bool useSharedMemory = false; |
| 209 EXPECT_TRUE(bridge->PrepareTextureMailbox(&textureMailbox, &releaseC
allback, useSharedMemory)); |
| 210 |
| 211 bool lostResource = true; |
| 212 releaseCallback->Run(gpu::SyncToken(), lostResource); |
| 224 } | 213 } |
| 225 | 214 |
| 226 // Retry with mailbox released while bridge destruction is in progress. | 215 // Retry with mailbox released while bridge destruction is in progress. |
| 227 { | 216 { |
| 228 FakeGLES2Interface gl; | 217 FakeGLES2Interface gl; |
| 229 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); | 218 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); |
| 230 WebExternalTextureMailbox mailbox; | 219 |
| 231 Canvas2DLayerBridge* rawBridge; | 220 cc::TextureMailbox textureMailbox; |
| 221 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; |
| 222 bool useSharedMemory = false; |
| 223 |
| 232 { | 224 { |
| 233 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(s
td::move(contextProvider), IntSize(300, 150), 0, NonOpaque, Canvas2DLayerBridge:
:ForceAccelerationForTesting))); | 225 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(s
td::move(contextProvider), IntSize(300, 150), 0, NonOpaque, Canvas2DLayerBridge:
:ForceAccelerationForTesting))); |
| 234 bridge->prepareMailbox(&mailbox, 0); | 226 bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback,
useSharedMemory); |
| 235 rawBridge = bridge.get(); | 227 // |bridge| goes out of scope and would normally be destroyed, b
ut object is kept alive by self references. |
| 236 } // bridge goes out of scope, but object is kept alive by self refe
rences. | 228 } |
| 229 |
| 237 // Before fixing crbug.com/411864, the following line you cause a me
mory use after free | 230 // Before fixing crbug.com/411864, the following line you cause a me
mory use after free |
| 238 // that sometimes causes a crash in normal builds and crashes consis
tently with ASAN. | 231 // that sometimes causes a crash in normal builds and crashes consis
tently with ASAN. |
| 239 rawBridge->mailboxReleased(mailbox, lostResource); // This should se
lf-destruct the bridge. | 232 // This should cause the bridge to be destroyed. |
| 233 bool lostResource = true; |
| 234 releaseCallback->Run(gpu::SyncToken(), lostResource); |
| 240 } | 235 } |
| 241 } | 236 } |
| 242 | 237 |
| 243 void accelerationHintTest() | 238 void accelerationHintTest() |
| 244 { | 239 { |
| 245 { | 240 { |
| 246 FakeGLES2Interface gl; | 241 FakeGLES2Interface gl; |
| 247 std::unique_ptr<FakeWebGraphicsContext3DProvider> contextProvider =
wrapUnique(new FakeWebGraphicsContext3DProvider(&gl)); | 242 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))); | 243 Canvas2DLayerBridgePtr bridge(adoptRef(new Canvas2DLayerBridge(std::
move(contextProvider), IntSize(300, 300), 0, NonOpaque, Canvas2DLayerBridge::Ena
bleAcceleration))); |
| 249 SkPaint paint; | 244 SkPaint paint; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 269 TEST_F(Canvas2DLayerBridgeTest, FullLifecycleSingleThreaded) | 264 TEST_F(Canvas2DLayerBridgeTest, FullLifecycleSingleThreaded) |
| 270 { | 265 { |
| 271 fullLifecycleTest(); | 266 fullLifecycleTest(); |
| 272 } | 267 } |
| 273 | 268 |
| 274 TEST_F(Canvas2DLayerBridgeTest, NoDrawOnContextLost) | 269 TEST_F(Canvas2DLayerBridgeTest, NoDrawOnContextLost) |
| 275 { | 270 { |
| 276 noDrawOnContextLostTest(); | 271 noDrawOnContextLostTest(); |
| 277 } | 272 } |
| 278 | 273 |
| 279 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWithBitmap) | 274 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxSoftware) |
| 280 { | 275 { |
| 281 prepareMailboxWithBitmapTest(); | 276 prepareMailboxSoftwareTest(); |
| 282 } | 277 } |
| 283 | 278 |
| 284 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxAndLoseResource) | 279 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxAndLoseResource) |
| 285 { | 280 { |
| 286 prepareMailboxAndLoseResourceTest(); | 281 prepareMailboxAndLoseResourceTest(); |
| 287 } | 282 } |
| 288 | 283 |
| 289 TEST_F(Canvas2DLayerBridgeTest, AccelerationHint) | 284 TEST_F(Canvas2DLayerBridgeTest, AccelerationHint) |
| 290 { | 285 { |
| 291 accelerationHintTest(); | 286 accelerationHintTest(); |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 // Test entering hibernation | 996 // Test entering hibernation |
| 1002 std::unique_ptr<WaitableEvent> hibernationStartedEvent = wrapUnique(new Wait
ableEvent()); | 997 std::unique_ptr<WaitableEvent> hibernationStartedEvent = wrapUnique(new Wait
ableEvent()); |
| 1003 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe
rnationScheduled)); | 998 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe
rnationScheduled)); |
| 1004 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) | 999 EXPECT_CALL(*mockLoggerPtr, didStartHibernating()) |
| 1005 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), &WaitableEvent:
:signal)); | 1000 .WillOnce(testing::Invoke(hibernationStartedEvent.get(), &WaitableEvent:
:signal)); |
| 1006 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); | 1001 postSetIsHiddenTask(BLINK_FROM_HERE, testThread.get(), bridge.get(), true); |
| 1007 hibernationStartedEvent->wait(); | 1002 hibernationStartedEvent->wait(); |
| 1008 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); | 1003 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); |
| 1009 | 1004 |
| 1010 // Test prepareMailbox while hibernating | 1005 // Test prepareMailbox while hibernating |
| 1011 WebExternalTextureMailbox mailbox; | 1006 cc::TextureMailbox textureMailbox; |
| 1012 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); | 1007 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; |
| 1008 bool useSharedMemory = false; |
| 1009 EXPECT_FALSE(bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback
, useSharedMemory)); |
| 1013 EXPECT_TRUE(bridge->checkSurfaceValid()); | 1010 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 1014 | 1011 |
| 1015 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 1012 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 1016 // without crashing due to thread checks | 1013 // without crashing due to thread checks |
| 1017 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe
rnationEndedWithTeardown)); | 1014 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe
rnationEndedWithTeardown)); |
| 1018 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 1015 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 1019 } | 1016 } |
| 1020 | 1017 |
| 1021 #if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU | 1018 #if CANVAS2D_HIBERNATION_ENABLED && CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU |
| 1022 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhileBackgroundRendering) | 1019 TEST_F(Canvas2DLayerBridgeTest, PrepareMailboxWhileBackgroundRendering) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1048 | 1045 |
| 1049 // Rendering in the background -> temp switch to SW | 1046 // Rendering in the background -> temp switch to SW |
| 1050 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe
rnationEndedWithSwitchToBackgroundRendering)); | 1047 EXPECT_CALL(*mockLoggerPtr, reportHibernationEvent(Canvas2DLayerBridge::Hibe
rnationEndedWithSwitchToBackgroundRendering)); |
| 1051 postAndWaitRenderingTask(BLINK_FROM_HERE, testThread.get(), bridge.get()); | 1048 postAndWaitRenderingTask(BLINK_FROM_HERE, testThread.get(), bridge.get()); |
| 1052 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); | 1049 ::testing::Mock::VerifyAndClearExpectations(mockLoggerPtr); |
| 1053 EXPECT_FALSE(bridge->isAccelerated()); | 1050 EXPECT_FALSE(bridge->isAccelerated()); |
| 1054 EXPECT_FALSE(bridge->isHibernating()); | 1051 EXPECT_FALSE(bridge->isHibernating()); |
| 1055 EXPECT_TRUE(bridge->checkSurfaceValid()); | 1052 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 1056 | 1053 |
| 1057 // Test prepareMailbox while background rendering | 1054 // Test prepareMailbox while background rendering |
| 1058 WebExternalTextureMailbox mailbox; | 1055 cc::TextureMailbox textureMailbox; |
| 1059 EXPECT_FALSE(bridge->prepareMailbox(&mailbox, 0)); | 1056 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; |
| 1057 bool useSharedMemory = false; |
| 1058 EXPECT_FALSE(bridge->PrepareTextureMailbox(&textureMailbox, &releaseCallback
, useSharedMemory)); |
| 1060 EXPECT_TRUE(bridge->checkSurfaceValid()); | 1059 EXPECT_TRUE(bridge->checkSurfaceValid()); |
| 1061 | 1060 |
| 1062 // Tear down the bridge on the thread so that 'bridge' can go out of scope | 1061 // Tear down the bridge on the thread so that 'bridge' can go out of scope |
| 1063 // without crashing due to thread checks | 1062 // without crashing due to thread checks |
| 1064 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); | 1063 postAndWaitDestroyBridgeTask(BLINK_FROM_HERE, testThread.get(), &bridge); |
| 1065 } | 1064 } |
| 1066 | 1065 |
| 1067 } // namespace blink | 1066 } // namespace blink |
| OLD | NEW |