summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordongseong.hwang@intel.com <dongseong.hwang@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-23 14:05:44 +0000
committerdongseong.hwang@intel.com <dongseong.hwang@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-23 14:05:44 +0000
commita8e8bcbce682003aa2d1163e3ac1662270177135 (patch)
tree1b822102466e11ae04e30ab2096cdf9c7876c377 /cc
parent3efee417c0161cafe4798a089e7f36bea8e2b8ba (diff)
downloadchromium_src-a8e8bcbce682003aa2d1163e3ac1662270177135.zip
chromium_src-a8e8bcbce682003aa2d1163e3ac1662270177135.tar.gz
chromium_src-a8e8bcbce682003aa2d1163e3ac1662270177135.tar.bz2
ÜC: Optimize the parent compositor receiving textures from the child.
This CL makes the parent compositor delay texture binding until they are used. So we have two benefits: 1. reduce unnecessary glBindTexture calls. 2. be able to wait "less" because of more time for glWaitSyncPointCHROMIUM. TEST=ResourceProviderTest.TransferGLResources, ResourceProviderTest.TextureFilters_ChildNearestParentLinear, ResourceProviderTest.TextureFilters_ChildLinearParentNearest BUG=N/A Review URL: https://codereview.chromium.org/132233044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246591 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/resources/resource_provider.cc41
-rw-r--r--cc/resources/resource_provider_unittest.cc14
-rw-r--r--cc/trees/layer_tree_host_unittest_delegated.cc7
3 files changed, 35 insertions, 27 deletions
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 4579126..82b4372 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -733,20 +733,18 @@ const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) {
LazyCreate(resource);
- if (resource->external) {
- if (!resource->gl_id && resource->mailbox.IsTexture()) {
- GLES2Interface* gl = ContextGL();
- DCHECK(gl);
- if (resource->mailbox.sync_point()) {
- GLC(gl, gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()));
- resource->mailbox.ResetSyncPoint();
- }
- resource->gl_id = texture_id_allocator_->NextId();
- GLC(gl, gl->BindTexture(resource->target, resource->gl_id));
- GLC(gl,
- gl->ConsumeTextureCHROMIUM(resource->target,
- resource->mailbox.data()));
+ if (!resource->gl_id && resource->mailbox.IsTexture()) {
+ GLES2Interface* gl = ContextGL();
+ DCHECK(gl);
+ if (resource->mailbox.sync_point()) {
+ GLC(gl, gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()));
+ resource->mailbox.ResetSyncPoint();
}
+ resource->gl_id = texture_id_allocator_->NextId();
+ GLC(gl, gl->BindTexture(resource->target, resource->gl_id));
+ GLC(gl,
+ gl->ConsumeTextureCHROMIUM(resource->target,
+ resource->mailbox.data()));
}
resource->lock_for_read_count++;
@@ -1077,19 +1075,7 @@ void ResourceProvider::ReceiveFromChild(
resource = Resource(
pixels, bitmap.release(), it->size, GL_LINEAR, GL_CLAMP_TO_EDGE);
} else {
- GLuint texture_id;
- // NOTE: If the parent is a browser and the child a renderer, the parent
- // is not supposed to have its context wait, because that could induce
- // deadlocks and/or security issues. The caller is responsible for
- // waiting asynchronously, and resetting sync_point before calling this.
- // However if the parent is a renderer (e.g. browser tag), it may be ok
- // (and is simpler) to wait.
- if (it->sync_point)
- GLC(gl, gl->WaitSyncPointCHROMIUM(it->sync_point));
- texture_id = texture_id_allocator_->NextId();
- GLC(gl, gl->BindTexture(it->target, texture_id));
- GLC(gl, gl->ConsumeTextureCHROMIUM(it->target, it->mailbox.name));
- resource = Resource(texture_id,
+ resource = Resource(0,
it->size,
it->target,
it->filter,
@@ -1097,7 +1083,8 @@ void ResourceProvider::ReceiveFromChild(
GL_CLAMP_TO_EDGE,
TextureUsageAny,
it->format);
- resource.mailbox.SetName(it->mailbox);
+ resource.mailbox =
+ TextureMailbox(it->mailbox, it->target, it->sync_point);
}
resource.child_id = child;
// Don't allocate a texture for a child.
diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc
index 52de843..f96982f 100644
--- a/cc/resources/resource_provider_unittest.cc
+++ b/cc/resources/resource_provider_unittest.cc
@@ -173,6 +173,8 @@ class ResourceProviderContext : public TestWebGraphicsContext3D {
last_waited_sync_point_ = std::max(sync_point, last_waited_sync_point_);
}
+ unsigned last_waited_sync_point() const { return last_waited_sync_point_; }
+
virtual void texStorage2DEXT(GLenum target,
GLint levels,
GLuint internalformat,
@@ -683,7 +685,9 @@ TEST_P(ResourceProviderTest, TransferGLResources) {
ASSERT_EQ(4u, list.size());
EXPECT_NE(0u, list[0].sync_point);
EXPECT_NE(0u, list[1].sync_point);
+ EXPECT_EQ(list[0].sync_point, list[1].sync_point);
EXPECT_NE(0u, list[2].sync_point);
+ EXPECT_EQ(list[0].sync_point, list[2].sync_point);
EXPECT_EQ(external_sync_point, list[3].sync_point);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[0].target);
EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), list[1].target);
@@ -694,6 +698,12 @@ TEST_P(ResourceProviderTest, TransferGLResources) {
EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id3));
EXPECT_TRUE(child_resource_provider_->InUseByConsumer(id4));
resource_provider_->ReceiveFromChild(child_id, list);
+ EXPECT_NE(list[0].sync_point, context3d_->last_waited_sync_point());
+ {
+ ResourceProvider::ScopedReadLockGL lock(resource_provider_.get(),
+ list[0].id);
+ }
+ EXPECT_EQ(list[0].sync_point, context3d_->last_waited_sync_point());
resource_provider_->DeclareUsedResourcesFromChild(child_id,
resource_ids_to_transfer);
}
@@ -1589,6 +1599,10 @@ class ResourceProviderTestTextureFilters : public ResourceProviderTest {
bindTexture(GL_TEXTURE_2D, parent_texture_id));
EXPECT_CALL(*parent_context, consumeTextureCHROMIUM(GL_TEXTURE_2D, _));
parent_resource_provider->ReceiveFromChild(child_id, list);
+ {
+ ResourceProvider::ScopedReadLockGL lock(parent_resource_provider.get(),
+ list[0].id);
+ }
Mock::VerifyAndClearExpectations(parent_context);
parent_resource_provider->DeclareUsedResourcesFromChild(
diff --git a/cc/trees/layer_tree_host_unittest_delegated.cc b/cc/trees/layer_tree_host_unittest_delegated.cc
index b5c400c..683c34d 100644
--- a/cc/trees/layer_tree_host_unittest_delegated.cc
+++ b/cc/trees/layer_tree_host_unittest_delegated.cc
@@ -136,6 +136,13 @@ class LayerTreeHostDelegatedTest : public LayerTreeTest {
TransferableResource resource;
resource.id = resource_id;
resource.target = GL_TEXTURE_2D;
+ GLbyte arbitrary_mailbox[64] = {
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
+ 1, 2, 3, 4
+ };
+ resource.mailbox.SetName(arbitrary_mailbox);
frame->resource_list.push_back(resource);
}