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

Side by Side Diff: Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

Issue 10883032: Merge 126540 - [chromium] Fix lost context when textures are evicted (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1229/
Patch Set: Created 8 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
« no previous file with comments | « Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10 matching lines...) Expand all
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 "config.h" 25 #include "config.h"
26 26
27 #include "cc/CCLayerTreeHost.h" 27 #include "cc/CCLayerTreeHost.h"
28 28
29 #include "AnimationIdVendor.h" 29 #include "AnimationIdVendor.h"
30 #include "CCOcclusionTrackerTestCommon.h" 30 #include "CCOcclusionTrackerTestCommon.h"
31 #include "CCSingleThreadProxy.h"
31 #include "CCThreadedTest.h" 32 #include "CCThreadedTest.h"
32 #include "ContentLayerChromium.h" 33 #include "ContentLayerChromium.h"
33 #include "GraphicsContext3DPrivate.h" 34 #include "GraphicsContext3DPrivate.h"
34 #include "cc/CCGraphicsContext.h" 35 #include "cc/CCGraphicsContext.h"
35 #include "cc/CCLayerTreeHostImpl.h" 36 #include "cc/CCLayerTreeHostImpl.h"
36 #include "cc/CCSettings.h" 37 #include "cc/CCSettings.h"
37 #include "cc/CCTextureUpdateQueue.h" 38 #include "cc/CCTextureUpdateQueue.h"
38 #include "cc/CCTimingFunction.h" 39 #include "cc/CCTimingFunction.h"
39 #include "platform/WebThread.h" 40 #include "platform/WebThread.h"
40 #include <gmock/gmock.h> 41 #include <gmock/gmock.h>
(...skipping 2548 matching lines...) Expand 10 before | Expand all | Expand 10 after
2589 RefPtr<EvictionTestLayer> m_layer; 2590 RefPtr<EvictionTestLayer> m_layer;
2590 CCLayerTreeHostImpl* m_implForEvictTextures; 2591 CCLayerTreeHostImpl* m_implForEvictTextures;
2591 int m_numCommits; 2592 int m_numCommits;
2592 }; 2593 };
2593 2594
2594 TEST_F(CCLayerTreeHostTestEvictTextures, runMultiThread) 2595 TEST_F(CCLayerTreeHostTestEvictTextures, runMultiThread)
2595 { 2596 {
2596 runTest(true); 2597 runTest(true);
2597 } 2598 }
2598 2599
2600 class CCLayerTreeHostTestLostContextAfterEvictTextures : public CCLayerTreeHostT est {
2601 public:
2602 CCLayerTreeHostTestLostContextAfterEvictTextures()
2603 : m_layer(EvictionTestLayer::create())
2604 , m_implForEvictTextures(0)
2605 , m_numCommits(0)
2606 {
2607 }
2608
2609 virtual void beginTest() OVERRIDE
2610 {
2611 m_layerTreeHost->setRootLayer(m_layer);
2612 m_layerTreeHost->setViewportSize(IntSize(10, 20), IntSize(10, 20));
2613
2614 WebTransformationMatrix identityMatrix;
2615 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, FloatPoin t(0, 0), FloatPoint(0, 0), IntSize(10, 20), true);
2616 }
2617
2618 class EvictTexturesTask : public WebKit::WebThread::Task {
2619 public:
2620 EvictTexturesTask(CCLayerTreeHostTestLostContextAfterEvictTextures* test ) : m_test(test) { }
2621 virtual ~EvictTexturesTask() { }
2622 virtual void run() OVERRIDE
2623 {
2624 m_test->evictTexturesOnImplThread();
2625 }
2626
2627 private:
2628 CCLayerTreeHostTestLostContextAfterEvictTextures* m_test;
2629 };
2630
2631 void postEvictTextures()
2632 {
2633 if (webThread())
2634 webThread()->postTask(new EvictTexturesTask(this));
2635 else {
2636 DebugScopedSetImplThread impl;
2637 evictTexturesOnImplThread();
2638 }
2639 }
2640
2641 void evictTexturesOnImplThread()
2642 {
2643 ASSERT(m_implForEvictTextures);
2644 m_implForEvictTextures->releaseContentsTextures();
2645 }
2646
2647 // Commit 1: Just commit and draw normally, then at the end, set ourselves
2648 // invisible (to prevent a commit that would recreate textures after
2649 // eviction, before the context recovery), and post a task that will evict
2650 // textures, then cause the context to be lost, and then set ourselves
2651 // visible again (to allow commits, since that's what causes context
2652 // recovery in single thread).
2653 virtual void didCommitAndDrawFrame() OVERRIDE
2654 {
2655 ++m_numCommits;
2656 switch (m_numCommits) {
2657 case 1:
2658 EXPECT_TRUE(m_layer->updated());
2659 m_layerTreeHost->setVisible(false);
2660 postEvictTextures();
2661 m_layerTreeHost->loseContext(1);
2662 m_layerTreeHost->setVisible(true);
2663 break;
2664 default:
2665 break;
2666 }
2667 }
2668
2669 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) OVERRIDE
2670 {
2671 m_implForEvictTextures = impl;
2672 }
2673
2674 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE
2675 {
2676 EXPECT_TRUE(succeeded);
2677 endTest();
2678 }
2679
2680 virtual void afterTest() OVERRIDE
2681 {
2682 }
2683
2684 private:
2685 MockContentLayerDelegate m_delegate;
2686 RefPtr<EvictionTestLayer> m_layer;
2687 CCLayerTreeHostImpl* m_implForEvictTextures;
2688 int m_numCommits;
2689 };
2690
2691 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLostContextAfterEvictTextures)
2692
2599 } // namespace 2693 } // namespace
OLDNEW
« no previous file with comments | « Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698