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

Side by Side Diff: cc/layers/texture_layer_unittest.cc

Issue 131683005: cc: Make PrepareToDraw return an enum for why it aborts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/layers/texture_layer.h" 5 #include "cc/layers/texture_layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 NOTREACHED(); 1395 NOTREACHED();
1396 break; 1396 break;
1397 } 1397 }
1398 } 1398 }
1399 1399
1400 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1400 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
1401 base::AutoLock lock(lock_); 1401 base::AutoLock lock(lock_);
1402 expected_used_textures_on_draw_ = expected_used_textures_on_commit_; 1402 expected_used_textures_on_draw_ = expected_used_textures_on_commit_;
1403 } 1403 }
1404 1404
1405 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 1405 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
1406 LayerTreeHostImpl::FrameData* frame_data, 1406 LayerTreeHostImpl* host_impl,
1407 bool result) OVERRIDE { 1407 LayerTreeHostImpl::FrameData* frame_data,
1408 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
1408 ContextForImplThread(host_impl)->ResetUsedTextures(); 1409 ContextForImplThread(host_impl)->ResetUsedTextures();
1409 return true; 1410 return DrawSwapReadbackResult::DID_DRAW;
1410 } 1411 }
1411 1412
1412 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 1413 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
1413 bool result) OVERRIDE { 1414 bool result) OVERRIDE {
1414 ASSERT_TRUE(result); 1415 ASSERT_TRUE(result);
1415 EXPECT_EQ(expected_used_textures_on_draw_, 1416 EXPECT_EQ(expected_used_textures_on_draw_,
1416 ContextForImplThread(host_impl)->NumUsedTextures()); 1417 ContextForImplThread(host_impl)->NumUsedTextures());
1417 } 1418 }
1418 1419
1419 virtual void AfterTest() OVERRIDE {} 1420 virtual void AfterTest() OVERRIDE {}
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 break; 1542 break;
1542 } 1543 }
1543 } 1544 }
1544 1545
1545 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1546 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
1546 ASSERT_TRUE(proxy()->IsMainThreadBlocked()); 1547 ASSERT_TRUE(proxy()->IsMainThreadBlocked());
1547 // This is the only texture that can be drawn this frame. 1548 // This is the only texture that can be drawn this frame.
1548 expected_texture_on_draw_ = texture_; 1549 expected_texture_on_draw_ = texture_;
1549 } 1550 }
1550 1551
1551 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 1552 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
1552 LayerTreeHostImpl::FrameData* frame_data, 1553 LayerTreeHostImpl* host_impl,
1553 bool result) OVERRIDE { 1554 LayerTreeHostImpl::FrameData* frame_data,
1555 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
1554 ContextForImplThread(host_impl)->ResetUsedTextures(); 1556 ContextForImplThread(host_impl)->ResetUsedTextures();
1555 return true; 1557 return DrawSwapReadbackResult::DID_DRAW;
1556 } 1558 }
1557 1559
1558 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, 1560 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
1559 bool result) OVERRIDE { 1561 bool result) OVERRIDE {
1560 ASSERT_TRUE(result); 1562 ASSERT_TRUE(result);
1561 TestWebGraphicsContext3D* context = ContextForImplThread(host_impl); 1563 TestWebGraphicsContext3D* context = ContextForImplThread(host_impl);
1562 int used_textures = context->NumUsedTextures(); 1564 int used_textures = context->NumUsedTextures();
1563 switch (host_impl->active_tree()->source_frame_number()) { 1565 switch (host_impl->active_tree()->source_frame_number()) {
1564 case 0: 1566 case 0:
1565 EXPECT_EQ(1, used_textures); 1567 EXPECT_EQ(1, used_textures);
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 root->AddChild(texture_layer_); 1977 root->AddChild(texture_layer_);
1976 1978
1977 layer_tree_host()->SetRootLayer(root); 1979 layer_tree_host()->SetRootLayer(root);
1978 LayerTreeTest::SetupTree(); 1980 LayerTreeTest::SetupTree();
1979 } 1981 }
1980 1982
1981 virtual void BeginTest() OVERRIDE { 1983 virtual void BeginTest() OVERRIDE {
1982 PostSetNeedsCommitToMainThread(); 1984 PostSetNeedsCommitToMainThread();
1983 } 1985 }
1984 1986
1985 virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 1987 virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
1986 LayerTreeHostImpl::FrameData* frame_data, 1988 LayerTreeHostImpl* host_impl,
1987 bool result) OVERRIDE { 1989 LayerTreeHostImpl::FrameData* frame_data,
1990 DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
1988 LayerImpl* root = host_impl->RootLayer(); 1991 LayerImpl* root = host_impl->RootLayer();
1989 TextureLayerImpl* texture_layer = 1992 TextureLayerImpl* texture_layer =
1990 static_cast<TextureLayerImpl*>(root->children()[0]); 1993 static_cast<TextureLayerImpl*>(root->children()[0]);
1991 if (++draw_count_ == 1) 1994 if (++draw_count_ == 1)
1992 EXPECT_EQ(0u, texture_layer->texture_id()); 1995 EXPECT_EQ(0u, texture_layer->texture_id());
1993 else 1996 else
1994 EXPECT_EQ(1u, texture_layer->texture_id()); 1997 EXPECT_EQ(1u, texture_layer->texture_id());
1995 return true; 1998 return DrawSwapReadbackResult::DID_DRAW;
1996 } 1999 }
1997 2000
1998 virtual void DidCommitAndDrawFrame() OVERRIDE { 2001 virtual void DidCommitAndDrawFrame() OVERRIDE {
1999 EndTest(); 2002 EndTest();
2000 } 2003 }
2001 2004
2002 virtual void AfterTest() OVERRIDE {} 2005 virtual void AfterTest() OVERRIDE {}
2003 2006
2004 private: 2007 private:
2005 scoped_refptr<TextureLayer> texture_layer_; 2008 scoped_refptr<TextureLayer> texture_layer_;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 int callback_count_; 2154 int callback_count_;
2152 scoped_refptr<Layer> root_; 2155 scoped_refptr<Layer> root_;
2153 scoped_refptr<TextureLayer> layer_; 2156 scoped_refptr<TextureLayer> layer_;
2154 }; 2157 };
2155 2158
2156 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 2159 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
2157 TextureLayerWithMailboxImplThreadDeleted); 2160 TextureLayerWithMailboxImplThreadDeleted);
2158 2161
2159 } // namespace 2162 } // namespace
2160 } // namespace cc 2163 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698