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

Unified Diff: cc/resources/resource_provider_unittest.cc

Issue 1336703002: Revert of Re-land: cc: Use worker context for one-copy tile initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/surfaces/display.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_provider_unittest.cc
diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc
index 7c65b73098b208ec4ed2916383c0deb148867ffc..4a02e828dcb79b611be09838cc0ed47389ef1ed8 100644
--- a/cc/resources/resource_provider_unittest.cc
+++ b/cc/resources/resource_provider_unittest.cc
@@ -422,11 +422,11 @@
resource_provider_ = ResourceProvider::Create(
output_surface_.get(), shared_bitmap_manager_.get(),
gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0,
- false, 1, use_image_texture_targets_);
+ false, 1, false, use_image_texture_targets_);
child_resource_provider_ = ResourceProvider::Create(
child_output_surface_.get(), shared_bitmap_manager_.get(),
gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0,
- false, 1, use_image_texture_targets_);
+ false, 1, false, use_image_texture_targets_);
}
ResourceProviderTest() : ResourceProviderTest(true) {}
@@ -1378,7 +1378,7 @@
scoped_ptr<ResourceProvider> child_resource_provider(ResourceProvider::Create(
child_output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
gfx::Size size(1, 1);
@@ -1863,7 +1863,7 @@
scoped_ptr<ResourceProvider> child_resource_provider(
ResourceProvider::Create(child_output_surface.get(),
shared_bitmap_manager.get(), NULL, NULL, 0,
- false, 1, use_image_texture_targets_));
+ false, 1, false, use_image_texture_targets_));
scoped_ptr<TextureStateTrackingContext> parent_context_owned(
new TextureStateTrackingContext);
@@ -1877,7 +1877,7 @@
scoped_ptr<ResourceProvider> parent_resource_provider(
ResourceProvider::Create(parent_output_surface.get(),
shared_bitmap_manager.get(), NULL, NULL, 0,
- false, 1, use_image_texture_targets_));
+ false, 1, false, use_image_texture_targets_));
gfx::Size size(1, 1);
ResourceFormat format = RGBA_8888;
@@ -2509,7 +2509,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
gfx::Size size(1, 1);
@@ -2592,7 +2592,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
gfx::Size size(1, 1);
@@ -2640,7 +2640,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
gfx::Size size(1, 1);
@@ -2691,7 +2691,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
gfx::Size size(1, 1);
@@ -2757,7 +2757,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
gpu_memory_buffer_manager_.get(), main_thread_task_runner_.get(), 0,
- false, 1, use_image_texture_targets_));
+ false, 1, false, use_image_texture_targets_));
uint32 release_sync_point = 0;
bool lost_resource = false;
@@ -2806,7 +2806,8 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager, gpu_memory_buffer_manager,
- main_thread_task_runner, 0, false, 1, use_image_texture_targets_));
+ main_thread_task_runner, 0, false, 1, false,
+ use_image_texture_targets_));
unsigned texture_id = 1;
uint32 sync_point = 30;
@@ -2949,7 +2950,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
uint32 sync_point = 30;
@@ -3019,7 +3020,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
uint32 sync_point = 30;
@@ -3073,7 +3074,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
uint32 sync_point = 0;
@@ -3194,7 +3195,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
gfx::Size size(2, 2);
@@ -3269,7 +3270,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
gfx::Size size(2, 2);
@@ -3325,7 +3326,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
gfx::Size size(2, 2);
@@ -3380,7 +3381,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
id = resource_provider->CreateResource(
@@ -3423,7 +3424,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
id = resource_provider->CreateResource(
@@ -3466,7 +3467,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id));
@@ -3507,7 +3508,7 @@
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
id = resource_provider->CreateResource(
@@ -3568,6 +3569,89 @@
.RetiresOnSaturation();
}
+TEST_P(ResourceProviderTest, CopyResource_GLTexture) {
+ if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
+ return;
+ scoped_ptr<AllocationTrackingContext3D> context_owned(
+ new StrictMock<AllocationTrackingContext3D>);
+ AllocationTrackingContext3D* context = context_owned.get();
+ context_owned->set_support_sync_query(true);
+
+ FakeOutputSurfaceClient output_surface_client;
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
+ ASSERT_TRUE(output_surface->BindToClient(&output_surface_client));
+
+ const int kWidth = 2;
+ const int kHeight = 2;
+ gfx::Size size(kWidth, kHeight);
+ ResourceFormat format = RGBA_8888;
+ ResourceId source_id = 0;
+ ResourceId dest_id = 0;
+ const unsigned kSourceTextureId = 123u;
+ const unsigned kDestTextureId = 321u;
+ const unsigned kImageId = 234u;
+
+ scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
+ output_surface.get(), shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
+ std::vector<unsigned>(static_cast<size_t>(gfx::BufferFormat::LAST) + 1,
+ GL_TEXTURE_2D)));
+
+ source_id = resource_provider->CreateResource(
+ size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
+
+ EXPECT_CALL(*context, NextTextureId())
+ .WillOnce(Return(kSourceTextureId))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kSourceTextureId))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA))
+ .WillOnce(Return(kImageId))
+ .RetiresOnSaturation();
+ {
+ ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
+ resource_provider.get(), source_id);
+ EXPECT_TRUE(lock.GetGpuMemoryBuffer());
+ }
+ Mock::VerifyAndClearExpectations(context);
+
+ dest_id = resource_provider->CreateResource(
+ size, GL_CLAMP_TO_EDGE, ResourceProvider::TEXTURE_HINT_IMMUTABLE, format);
+
+ EXPECT_CALL(*context, NextTextureId())
+ .WillOnce(Return(kDestTextureId))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kDestTextureId))
+ .Times(2)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*context, texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, nullptr))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kSourceTextureId))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*context, bindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId))
+ .Times(1)
+ .RetiresOnSaturation();
+ resource_provider->CopyResource(source_id, dest_id, gfx::Rect(size));
+ Mock::VerifyAndClearExpectations(context);
+
+ EXPECT_CALL(*context, destroyImageCHROMIUM(kImageId))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*context, RetireTextureId(kSourceTextureId))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*context, RetireTextureId(kDestTextureId))
+ .Times(1)
+ .RetiresOnSaturation();
+ resource_provider->DeleteResource(source_id);
+ resource_provider->DeleteResource(dest_id);
+}
+
TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) {
if (GetParam() != ResourceProvider::RESOURCE_TYPE_GL_TEXTURE)
return;
@@ -3585,7 +3669,7 @@
gfx::Size size(4, 4);
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
int texture_id = 123;
@@ -3617,7 +3701,7 @@
gfx::Size size(4, 4);
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager_.get(),
- gpu_memory_buffer_manager_.get(), NULL, 0, false, 1,
+ gpu_memory_buffer_manager_.get(), NULL, 0, false, 1, false,
use_image_texture_targets_));
int texture_id = 123;
uint8_t pixels[8];
@@ -3674,7 +3758,7 @@
size_t kTextureAllocationChunkSize = 1;
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false,
- kTextureAllocationChunkSize,
+ kTextureAllocationChunkSize, false,
ResourceProviderTest::use_image_texture_targets()));
ResourceId id = resource_provider->CreateResource(
@@ -3691,7 +3775,7 @@
size_t kTextureAllocationChunkSize = 8;
scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
output_surface.get(), shared_bitmap_manager.get(), NULL, NULL, 0, false,
- kTextureAllocationChunkSize,
+ kTextureAllocationChunkSize, false,
ResourceProviderTest::use_image_texture_targets()));
ResourceId id = resource_provider->CreateResource(
« no previous file with comments | « cc/resources/resource_provider.cc ('k') | cc/surfaces/display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698