OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCLayerTreeHost.h" | 7 #include "CCLayerTreeHost.h" |
8 | 8 |
9 #include "CCGraphicsContext.h" | 9 #include "CCGraphicsContext.h" |
10 #include "CCLayerTreeHostImpl.h" | 10 #include "CCLayerTreeHostImpl.h" |
11 #include "CCOcclusionTrackerTestCommon.h" | 11 #include "CCOcclusionTrackerTestCommon.h" |
12 #include "CCSettings.h" | 12 #include "CCSettings.h" |
13 #include "CCSingleThreadProxy.h" | 13 #include "CCSingleThreadProxy.h" |
14 #include "CCTextureUpdateQueue.h" | 14 #include "CCTextureUpdateQueue.h" |
15 #include "CCThreadedTest.h" | 15 #include "CCThreadedTest.h" |
16 #include "CCTimingFunction.h" | 16 #include "CCTimingFunction.h" |
17 #include "ContentLayerChromium.h" | 17 #include "ContentLayerChromium.h" |
| 18 #include "Extensions3DChromium.h" |
| 19 #include "FakeWebCompositorOutputSurface.h" |
18 #include <gmock/gmock.h> | 20 #include <gmock/gmock.h> |
19 #include <gtest/gtest.h> | 21 #include <gtest/gtest.h> |
20 #include <public/Platform.h> | 22 #include <public/Platform.h> |
21 #include <public/WebThread.h> | 23 #include <public/WebThread.h> |
22 #include <wtf/MainThread.h> | 24 #include <wtf/MainThread.h> |
23 #include <wtf/OwnArrayPtr.h> | 25 #include <wtf/OwnArrayPtr.h> |
24 | 26 |
25 using namespace WebCore; | 27 using namespace WebCore; |
26 using namespace WebKit; | 28 using namespace WebKit; |
27 using namespace WebKitTests; | 29 using namespace WebKitTests; |
(...skipping 2354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2382 }; | 2384 }; |
2383 | 2385 |
2384 class EvictionTestLayerImpl : public CCLayerImpl { | 2386 class EvictionTestLayerImpl : public CCLayerImpl { |
2385 public: | 2387 public: |
2386 static PassOwnPtr<EvictionTestLayerImpl> create(int id) | 2388 static PassOwnPtr<EvictionTestLayerImpl> create(int id) |
2387 { | 2389 { |
2388 return adoptPtr(new EvictionTestLayerImpl(id)); | 2390 return adoptPtr(new EvictionTestLayerImpl(id)); |
2389 } | 2391 } |
2390 virtual ~EvictionTestLayerImpl() { } | 2392 virtual ~EvictionTestLayerImpl() { } |
2391 | 2393 |
2392 virtual void appendQuads(CCQuadSink&, bool& hadMissingTiles) OVERRIDE | 2394 virtual void appendQuads(CCQuadSink& quadSink, CCAppendQuadsData&) OVERRIDE |
2393 { | 2395 { |
2394 ASSERT_TRUE(m_hasTexture); | 2396 ASSERT_TRUE(m_hasTexture); |
2395 ASSERT_NE(0u, layerTreeHostImpl()->resourceProvider()->numResources()); | 2397 ASSERT_NE(0u, layerTreeHostImpl()->resourceProvider()->numResources()); |
2396 } | 2398 } |
2397 | 2399 |
2398 void setHasTexture(bool hasTexture) { m_hasTexture = hasTexture; } | 2400 void setHasTexture(bool hasTexture) { m_hasTexture = hasTexture; } |
2399 | 2401 |
2400 private: | 2402 private: |
2401 explicit EvictionTestLayerImpl(int id) | 2403 explicit EvictionTestLayerImpl(int id) |
2402 : CCLayerImpl(id) | 2404 : CCLayerImpl(id) |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2661 | 2663 |
2662 private: | 2664 private: |
2663 MockContentLayerDelegate m_delegate; | 2665 MockContentLayerDelegate m_delegate; |
2664 RefPtr<EvictionTestLayer> m_layer; | 2666 RefPtr<EvictionTestLayer> m_layer; |
2665 CCLayerTreeHostImpl* m_implForEvictTextures; | 2667 CCLayerTreeHostImpl* m_implForEvictTextures; |
2666 int m_numCommits; | 2668 int m_numCommits; |
2667 }; | 2669 }; |
2668 | 2670 |
2669 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLostContextAfterEvictTextures) | 2671 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLostContextAfterEvictTextures) |
2670 | 2672 |
| 2673 class CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostContext : public
WebKit::CompositorFakeWebGraphicsContext3D { |
| 2674 public: |
| 2675 static PassOwnPtr<CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostC
ontext> create(Attributes attrs) |
| 2676 { |
| 2677 return adoptPtr(new CompositorFakeWebGraphicsContext3DWithEndQueryCausin
gLostContext(attrs)); |
| 2678 } |
| 2679 |
| 2680 virtual void setContextLostCallback(WebGraphicsContextLostCallback* callback
) { m_contextLostCallback = callback; } |
| 2681 virtual bool isContextLost() { return m_isContextLost; } |
| 2682 |
| 2683 virtual void beginQueryEXT(GC3Denum, WebGLId) { } |
| 2684 virtual void endQueryEXT(GC3Denum) |
| 2685 { |
| 2686 // Lose context. |
| 2687 if (!m_isContextLost) { |
| 2688 m_contextLostCallback->onContextLost(); |
| 2689 m_isContextLost = true; |
| 2690 } |
| 2691 } |
| 2692 virtual void getQueryObjectuivEXT(WebGLId, GC3Denum pname, GC3Duint* params) |
| 2693 { |
| 2694 // Context is lost. Result will never be available. |
| 2695 if (pname == Extensions3DChromium::QUERY_RESULT_AVAILABLE_EXT) |
| 2696 *params = 0; |
| 2697 } |
| 2698 |
| 2699 private: |
| 2700 explicit CompositorFakeWebGraphicsContext3DWithEndQueryCausingLostContext(At
tributes attrs) |
| 2701 : CompositorFakeWebGraphicsContext3D(attrs) |
| 2702 , m_contextLostCallback(0) |
| 2703 , m_isContextLost(false) { } |
| 2704 |
| 2705 WebGraphicsContextLostCallback* m_contextLostCallback; |
| 2706 bool m_isContextLost; |
| 2707 }; |
| 2708 |
| 2709 class CCLayerTreeHostTestLostContextWhileUpdatingResources : public CCLayerTreeH
ostTest { |
| 2710 public: |
| 2711 CCLayerTreeHostTestLostContextWhileUpdatingResources() |
| 2712 : m_parent(ContentLayerChromiumWithUpdateTracking::create(&m_delegate)) |
| 2713 , m_numChildren(50) |
| 2714 { |
| 2715 for (int i = 0; i < m_numChildren; i++) |
| 2716 m_children.append(ContentLayerChromiumWithUpdateTracking::create(&m_
delegate)); |
| 2717 } |
| 2718 |
| 2719 virtual PassOwnPtr<WebKit::WebCompositorOutputSurface> createOutputSurface() |
| 2720 { |
| 2721 return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsC
ontext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes(
))); |
| 2722 } |
| 2723 |
| 2724 virtual void beginTest() |
| 2725 { |
| 2726 m_layerTreeHost->setRootLayer(m_parent); |
| 2727 m_layerTreeHost->setViewportSize(IntSize(m_numChildren, 1), IntSize(m_nu
mChildren, 1)); |
| 2728 |
| 2729 WebTransformationMatrix identityMatrix; |
| 2730 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, FloatPoi
nt(0, 0), FloatPoint(0, 0), IntSize(m_numChildren, 1), true); |
| 2731 for (int i = 0; i < m_numChildren; i++) |
| 2732 setLayerPropertiesForTesting(m_children[i].get(), m_parent.get(), id
entityMatrix, FloatPoint(0, 0), FloatPoint(i, 0), IntSize(1, 1), false); |
| 2733 |
| 2734 postSetNeedsCommitToMainThread(); |
| 2735 } |
| 2736 |
| 2737 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) |
| 2738 { |
| 2739 endTest(); |
| 2740 } |
| 2741 |
| 2742 virtual void layout() |
| 2743 { |
| 2744 m_parent->setNeedsDisplay(); |
| 2745 for (int i = 0; i < m_numChildren; i++) |
| 2746 m_children[i]->setNeedsDisplay(); |
| 2747 } |
| 2748 |
| 2749 virtual void afterTest() |
| 2750 { |
| 2751 } |
| 2752 |
| 2753 private: |
| 2754 MockContentLayerDelegate m_delegate; |
| 2755 RefPtr<ContentLayerChromiumWithUpdateTracking> m_parent; |
| 2756 int m_numChildren; |
| 2757 Vector<RefPtr<ContentLayerChromiumWithUpdateTracking> > m_children; |
| 2758 }; |
| 2759 |
| 2760 TEST_F(CCLayerTreeHostTestLostContextWhileUpdatingResources, runMultiThread) |
| 2761 { |
| 2762 runTest(true); |
| 2763 } |
| 2764 |
2671 } // namespace | 2765 } // namespace |
OLD | NEW |