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

Side by Side Diff: cc/resource_provider_unittest.cc

Issue 12321053: cc: Complete pending tile uploads if they are needed for tree activation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased after managed_tile_state refactoring. Created 7 years, 9 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
« no previous file with comments | « cc/resource_provider.cc ('k') | cc/tile_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/resource_provider.h" 5 #include "cc/resource_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "cc/output_surface.h" 9 #include "cc/output_surface.h"
10 #include "cc/scoped_ptr_deque.h" 10 #include "cc/scoped_ptr_deque.h"
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 WGC3Denum type, const void* pixels)); 872 WGC3Denum type, const void* pixels));
873 MOCK_METHOD9(texSubImage2D, void(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, 873 MOCK_METHOD9(texSubImage2D, void(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset,
874 WGC3Dsizei width, WGC3Dsizei height, WGC3De num format, 874 WGC3Dsizei width, WGC3Dsizei height, WGC3De num format,
875 WGC3Denum type, const void* pixels)); 875 WGC3Denum type, const void* pixels));
876 MOCK_METHOD9(asyncTexImage2DCHROMIUM, void(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, 876 MOCK_METHOD9(asyncTexImage2DCHROMIUM, void(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat,
877 WGC3Dsizei width, WGC3Dsizei heigh t, WGC3Dint border, WGC3Denum format, 877 WGC3Dsizei width, WGC3Dsizei heigh t, WGC3Dint border, WGC3Denum format,
878 WGC3Denum type, const void* pixels )); 878 WGC3Denum type, const void* pixels ));
879 MOCK_METHOD9(asyncTexSubImage2DCHROMIUM, void(WGC3Denum target, WGC3Dint lev el, WGC3Dint xoffset, WGC3Dint yoffset, 879 MOCK_METHOD9(asyncTexSubImage2DCHROMIUM, void(WGC3Denum target, WGC3Dint lev el, WGC3Dint xoffset, WGC3Dint yoffset,
880 WGC3Dsizei width, WGC3Dsizei h eight, WGC3Denum format, 880 WGC3Dsizei width, WGC3Dsizei h eight, WGC3Denum format,
881 WGC3Denum type, const void* pi xels)); 881 WGC3Denum type, const void* pi xels));
882 MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(WGC3Denum target));
882 }; 883 };
883 884
884 TEST_P(ResourceProviderTest, TextureAllocation) 885 TEST_P(ResourceProviderTest, TextureAllocation)
885 { 886 {
886 // Only for GL textures. 887 // Only for GL textures.
887 if (GetParam() != ResourceProvider::GLTexture) 888 if (GetParam() != ResourceProvider::GLTexture)
888 return; 889 return;
889 scoped_ptr<WebKit::WebGraphicsContext3D> mock_context( 890 scoped_ptr<WebKit::WebGraphicsContext3D> mock_context(
890 static_cast<WebKit::WebGraphicsContext3D*>(new NiceMock<AllocationTracki ngContext3D>)); 891 static_cast<WebKit::WebGraphicsContext3D*>(new NiceMock<AllocationTracki ngContext3D>));
891 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(mock_con text.Pass())); 892 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(mock_con text.Pass()));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)).Times(2); 942 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)).Times(2);
942 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_,_,_,2,2,_,_,_,_)).Times(1); 943 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_,_,_,2,2,_,_,_,_)).Times(1);
943 id = resourceProvider->CreateResource(size, format, ResourceProvider::Textur eUsageAny); 944 id = resourceProvider->CreateResource(size, format, ResourceProvider::Textur eUsageAny);
944 resourceProvider->AcquirePixelBuffer(id); 945 resourceProvider->AcquirePixelBuffer(id);
945 resourceProvider->BeginSetPixels(id); 946 resourceProvider->BeginSetPixels(id);
946 resourceProvider->ReleasePixelBuffer(id); 947 resourceProvider->ReleasePixelBuffer(id);
947 resourceProvider->DeleteResource(id); 948 resourceProvider->DeleteResource(id);
948 Mock::VerifyAndClearExpectations(context); 949 Mock::VerifyAndClearExpectations(context);
949 } 950 }
950 951
952 TEST_P(ResourceProviderTest, ForcingAsyncUploadToComplete)
953 {
954 // Only for GL textures.
955 if (GetParam() != ResourceProvider::GLTexture)
956 return;
957 scoped_ptr<WebKit::WebGraphicsContext3D> mock_context(
958 static_cast<WebKit::WebGraphicsContext3D*>(new NiceMock<AllocationTracki ngContext3D>));
959 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(mock_con text.Pass()));
960
961 gfx::Size size(2, 2);
962 WGC3Denum format = GL_RGBA;
963 ResourceProvider::ResourceId id = 0;
964 int textureId = 123;
965
966 AllocationTrackingContext3D* context = static_cast<AllocationTrackingContext 3D*>(outputSurface->context3d());
967 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outpu tSurface.get()));
968
969 EXPECT_CALL(*context, createTexture()).WillOnce(Return(textureId));
970 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)).Times(3);
971 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_,_,_,2,2,_,_,_,_)).Times(1);
972 EXPECT_CALL(*context, waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)).Times(1);
973 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, 0)).Times(1);
974 id = resourceProvider->CreateResource(size, format, ResourceProvider::Textur eUsageAny);
975 resourceProvider->AcquirePixelBuffer(id);
976 resourceProvider->BeginSetPixels(id);
977 resourceProvider->ForceSetPixelsToComplete(id);
978 resourceProvider->ReleasePixelBuffer(id);
979 Mock::VerifyAndClearExpectations(context);
980 }
981
982 TEST_P(ResourceProviderTest, AbortForcedAsyncUpload)
983 {
984 // Only for GL textures.
985 if (GetParam() != ResourceProvider::GLTexture)
986 return;
987 scoped_ptr<WebKit::WebGraphicsContext3D> mock_context(
988 static_cast<WebKit::WebGraphicsContext3D*>(new NiceMock<AllocationTracki ngContext3D>));
989 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(mock_con text.Pass()));
990
991 gfx::Size size(2, 2);
992 WGC3Denum format = GL_RGBA;
993 ResourceProvider::ResourceId id = 0;
994 int textureId = 123;
995
996 AllocationTrackingContext3D* context = static_cast<AllocationTrackingContext 3D*>(outputSurface->context3d());
997 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::Create(outpu tSurface.get()));
998
999 EXPECT_CALL(*context, createTexture()).WillRepeatedly(Return(textureId));
1000 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, textureId)).Times(4);
1001 EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_,_,_,2,2,_,_,_,_)).Times(1);
1002 EXPECT_CALL(*context, waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)).Times(1);
1003 EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, 0)).Times(1);
1004 EXPECT_CALL(*context, deleteTexture(_)).Times(1);
1005 id = resourceProvider->CreateResource(size, format, ResourceProvider::Textur eUsageAny);
1006 resourceProvider->AcquirePixelBuffer(id);
1007 resourceProvider->BeginSetPixels(id);
1008 resourceProvider->ForceSetPixelsToComplete(id);
1009 resourceProvider->AbortSetPixels(id);
1010 resourceProvider->ReleasePixelBuffer(id);
1011 Mock::VerifyAndClearExpectations(context);
1012 }
1013
951 INSTANTIATE_TEST_CASE_P(ResourceProviderTests, 1014 INSTANTIATE_TEST_CASE_P(ResourceProviderTests,
952 ResourceProviderTest, 1015 ResourceProviderTest,
953 ::testing::Values(ResourceProvider::GLTexture, 1016 ::testing::Values(ResourceProvider::GLTexture,
954 ResourceProvider::Bitmap)); 1017 ResourceProvider::Bitmap));
955 1018
956 } // namespace 1019 } // namespace
957 } // namespace cc 1020 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resource_provider.cc ('k') | cc/tile_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698