diff options
author | loislo@chromium.org <loislo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-20 06:28:40 +0000 |
---|---|---|
committer | loislo@chromium.org <loislo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-20 06:28:40 +0000 |
commit | 5e5e155948b49c26d17535f984a9fd03199fef23 (patch) | |
tree | 66c6f56fdcf4d9026b026a1f951393ee51d80639 /cc | |
parent | fd0b7f15f54de5eb43d4e6549c5040cae28e2049 (diff) | |
download | chromium_src-5e5e155948b49c26d17535f984a9fd03199fef23.zip chromium_src-5e5e155948b49c26d17535f984a9fd03199fef23.tar.gz chromium_src-5e5e155948b49c26d17535f984a9fd03199fef23.tar.bz2 |
Revert "cc: Defer texture allocation (to allow async allocations)."
This reverts commit 715d476d4225cd2ad2ff1c221b84a2764d57cd53.
It broke 11 video compositing layout tests.
compositing/geometry/video-fixed-scrolling.html
compositing/geometry/video-opacity-overlay.html
compositing/layers-inside-overflow-scroll.html
compositing/overflow/overflow-compositing-descendant.html
compositing/overflow/scroll-ancestor-update.html
compositing/self-painting-layers.html
compositing/visibility/visibility-simple-video-layer.html
platform/chromium/compositing/lost-compositor-context-with-video.html
platform/chromium/compositing/video-frame-size-change.html
platform/chromium/virtual/gpu/compositedscrolling/overflow/overflow-compositing-descendant.html
platform/chromium/virtual/gpu/compositedscrolling/overflow/scroll-ancestor-update.html
plugins/embed-attributes-setting.html
BUG=none
TEST=none
TBR=epenner
Review URL: https://codereview.chromium.org/11637032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174108 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/heads_up_display_layer_impl.cc | 8 | ||||
-rw-r--r-- | cc/layer_tree_host_impl_unittest.cc | 15 | ||||
-rw-r--r-- | cc/resource_provider.cc | 86 | ||||
-rw-r--r-- | cc/resource_provider.h | 6 | ||||
-rw-r--r-- | cc/resource_provider_unittest.cc | 74 | ||||
-rw-r--r-- | cc/test/render_pass_test_common.cc | 1 |
6 files changed, 20 insertions, 170 deletions
diff --git a/cc/heads_up_display_layer_impl.cc b/cc/heads_up_display_layer_impl.cc index dd8f413..73f99d0 100644 --- a/cc/heads_up_display_layer_impl.cc +++ b/cc/heads_up_display_layer_impl.cc @@ -76,14 +76,8 @@ void HeadsUpDisplayLayerImpl::willDraw(ResourceProvider* resourceProvider) if (m_hudTexture->size() != bounds()) m_hudTexture->Free(); - if (!m_hudTexture->id()) { + if (!m_hudTexture->id()) m_hudTexture->Allocate(bounds(), GL_RGBA, ResourceProvider::TextureUsageAny); - // TODO(epenner): This texture was being used before setPixels was called, - // which is now not allowed (it's an uninitialized read). This should be fixed - // and this allocateForTesting() removed. - // http://crbug.com/166784 - resourceProvider->allocateForTesting(m_hudTexture->id()); - } } void HeadsUpDisplayLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsData) diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc index 92c4371..8f9b4e3 100644 --- a/cc/layer_tree_host_impl_unittest.cc +++ b/cc/layer_tree_host_impl_unittest.cc @@ -1058,7 +1058,6 @@ private: setSkipsDraw(skipsDraw); if (!tileMissing) { ResourceProvider::ResourceId resource = resourceProvider->createResource(gfx::Size(), GL_RGBA, ResourceProvider::TextureUsageAny); - resourceProvider->allocateForTesting(resource); pushTileProperties(0, 0, resource, gfx::Rect(), false); } if (animating) @@ -1684,7 +1683,6 @@ private: , m_quadVisibleRect(5, 5, 5, 5) , m_resourceId(resourceProvider->createResource(gfx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny)) { - resourceProvider->allocateForTesting(m_resourceId); setAnchorPoint(gfx::PointF(0, 0)); setBounds(gfx::Size(10, 10)); setContentBounds(gfx::Size(10, 10)); @@ -2759,15 +2757,9 @@ public: ResourceProvider::TextureUsageHint hint = ResourceProvider::TextureUsageAny; setScrollbarGeometry(ScrollbarGeometryFixedThumb::create(FakeWebScrollbarThemeGeometryNonEmpty::create())); - ResourceProvider::ResourceId backId = provider->createResource(size, format, hint); - ResourceProvider::ResourceId foreId = provider->createResource(size, format, hint); - ResourceProvider::ResourceId thumbId = provider->createResource(size, format, hint); - provider->allocateForTesting(backId); - provider->allocateForTesting(foreId); - provider->allocateForTesting(thumbId); - setBackTrackResourceId(backId); - setForeTrackResourceId(foreId); - setThumbResourceId(thumbId); + setBackTrackResourceId(provider->createResource(size, format, hint)); + setForeTrackResourceId(provider->createResource(size, format, hint)); + setThumbResourceId(provider->createResource(size, format, hint)); } protected: @@ -2780,7 +2772,6 @@ protected: static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvider* provider) { ResourceProvider::ResourceId resourceId = provider->createResource(gfx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny); - provider->allocateForTesting(resourceId); scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), gfx::Transform()); diff --git a/cc/resource_provider.cc b/cc/resource_provider.cc index 8b7081c..2cbafae 100644 --- a/cc/resource_provider.cc +++ b/cc/resource_provider.cc @@ -59,7 +59,6 @@ ResourceProvider::Resource::Resource() , exported(false) , markedForDeletion(false) , pendingSetPixels(false) - , allocated(false) , size() , format(0) , filter(0) @@ -79,7 +78,6 @@ ResourceProvider::Resource::Resource(unsigned textureId, const gfx::Size& size, , exported(false) , markedForDeletion(false) , pendingSetPixels(false) - , allocated(false) , size(size) , format(format) , filter(filter) @@ -99,7 +97,6 @@ ResourceProvider::Resource::Resource(uint8_t* pixels, const gfx::Size& size, GLe , exported(false) , markedForDeletion(false) , pendingSetPixels(false) - , allocated(false) , size(size) , format(format) , filter(filter) @@ -186,19 +183,22 @@ ResourceProvider::ResourceId ResourceProvider::createGLTexture(const gfx::Size& DCHECK(context3d); GLC(context3d, textureId = context3d->createTexture()); GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); - - // Set texture properties. Allocation is delayed until needed. GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROMIUM, texturePool)); + if (m_useTextureUsageHint && hint == TextureUsageFramebuffer) GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); + if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) { + GLenum storageFormat = textureToStorageFormat(format); + GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageFormat, size.width(), size.height())); + } else + GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0)); ResourceId id = m_nextId++; Resource resource(textureId, size, format, GL_LINEAR); - resource.allocated = false; m_resources[id] = resource; return id; } @@ -211,7 +211,6 @@ ResourceProvider::ResourceId ResourceProvider::createBitmap(const gfx::Size& siz ResourceId id = m_nextId++; Resource resource(pixels, size, GL_RGBA, GL_LINEAR); - resource.allocated = true; m_resources[id] = resource; return id; } @@ -231,7 +230,6 @@ ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture ResourceId id = m_nextId++; Resource resource(textureId, gfx::Size(), 0, GL_LINEAR); resource.external = true; - resource.allocated = true; m_resources[id] = resource; return id; } @@ -242,9 +240,9 @@ void ResourceProvider::deleteResource(ResourceId id) ResourceMap::iterator it = m_resources.find(id); CHECK(it != m_resources.end()); Resource* resource = &it->second; + DCHECK(!resource->lockedForWrite); DCHECK(!resource->lockForReadCount); DCHECK(!resource->markedForDeletion); - DCHECK(resource->pendingSetPixels || !resource->lockedForWrite); if (resource->exported) { resource->markedForDeletion = true; @@ -297,10 +295,8 @@ void ResourceProvider::setPixels(ResourceId id, const uint8_t* image, const gfx: DCHECK(!resource->lockForReadCount); DCHECK(!resource->external); DCHECK(!resource->exported); - lazyAllocate(resource); if (resource->glId) { - DCHECK(!resource->pendingSetPixels); WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); DCHECK(context3d); DCHECK(m_textureUploader.get()); @@ -314,7 +310,6 @@ void ResourceProvider::setPixels(ResourceId id, const uint8_t* image, const gfx: } if (resource->pixels) { - DCHECK(resource->allocated); DCHECK(resource->format == GL_RGBA); SkBitmap srcFull; srcFull.setConfig(SkBitmap::kARGB_8888_Config, imageRect.width(), imageRect.height()); @@ -389,8 +384,6 @@ const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id) Resource* resource = &it->second; DCHECK(!resource->lockedForWrite); DCHECK(!resource->exported); - DCHECK(resource->allocated); // Uninitialized! Call setPixels or lockForWrite first. - resource->lockForReadCount++; return resource; } @@ -416,8 +409,6 @@ const ResourceProvider::Resource* ResourceProvider::lockForWrite(ResourceId id) DCHECK(!resource->lockForReadCount); DCHECK(!resource->exported); DCHECK(!resource->external); - lazyAllocate(resource); - resource->lockedForWrite = true; return resource; } @@ -654,8 +645,6 @@ void ResourceProvider::receiveFromChild(int child, const TransferableResourceLis ResourceId id = m_nextId++; Resource resource(textureId, it->size, it->format, it->filter); resource.mailbox.setName(it->mailbox.name); - // Don't allocate a texture for a child. - resource.allocated = true; m_resources[id] = resource; childInfo.parentToChildMap[id] = it->id; childInfo.childToParentMap[it->id] = id; @@ -696,7 +685,6 @@ bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceI DCHECK(!source->lockedForWrite); DCHECK(!source->lockForReadCount); DCHECK(!source->external); - DCHECK(source->allocated); if (source->exported) return false; resource->id = id; @@ -844,7 +832,6 @@ void ResourceProvider::setPixelsFromBuffer(ResourceId id) DCHECK(!resource->lockForReadCount); DCHECK(!resource->external); DCHECK(!resource->exported); - lazyAllocate(resource); if (resource->glId) { WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); @@ -906,10 +893,7 @@ void ResourceProvider::beginSetPixels(ResourceId id) CHECK(it != m_resources.end()); Resource* resource = &it->second; DCHECK(!resource->pendingSetPixels); - DCHECK(resource->glId || resource->allocated); - bool allocate = !resource->allocated; - resource->allocated = true; lockForWrite(id); if (resource->glId) { @@ -925,27 +909,15 @@ void ResourceProvider::beginSetPixels(ResourceId id) context3d->beginQueryEXT( GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM, resource->glUploadQueryId); - if (allocate) { - context3d->asyncTexImage2DCHROMIUM(GL_TEXTURE_2D, - 0, /* level */ - resource->format, - resource->size.width(), - resource->size.height(), - 0, /* border */ - resource->format, - GL_UNSIGNED_BYTE, - NULL); - } else { - context3d->asyncTexSubImage2DCHROMIUM(GL_TEXTURE_2D, - 0, /* level */ - 0, /* x */ - 0, /* y */ - resource->size.width(), - resource->size.height(), - resource->format, - GL_UNSIGNED_BYTE, - NULL); - } + context3d->asyncTexSubImage2DCHROMIUM(GL_TEXTURE_2D, + 0, /* level */ + 0, /* x */ + 0, /* y */ + resource->size.width(), + resource->size.height(), + resource->format, + GL_UNSIGNED_BYTE, + NULL); context3d->endQueryEXT(GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM); context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); } @@ -983,30 +955,4 @@ bool ResourceProvider::didSetPixelsComplete(ResourceId id) { return true; } -void ResourceProvider::allocateForTesting(ResourceId id) { - ResourceMap::iterator it = m_resources.find(id); - CHECK(it != m_resources.end()); - Resource* resource = &it->second; - lazyAllocate(resource); -} - -void ResourceProvider::lazyAllocate(Resource* resource) { - DCHECK(resource); - DCHECK(resource->glId || resource->allocated); - - if (resource->allocated || !resource->glId) - return; - - resource->allocated = true; - WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); - gfx::Size& size = resource->size; - GLenum format = resource->format; - if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) { - GLenum storageFormat = textureToStorageFormat(format); - GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageFormat, size.width(), size.height())); - } else - GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0)); -} - - } // namespace cc diff --git a/cc/resource_provider.h b/cc/resource_provider.h index 9b5b54b..d90d224 100644 --- a/cc/resource_provider.h +++ b/cc/resource_provider.h @@ -230,10 +230,6 @@ public: void beginSetPixels(ResourceId id); bool didSetPixelsComplete(ResourceId id); - // For tests only! This prevents detecting uninitialized reads. - // Use setPixels or lockForWrite to allocate implicitly. - void allocateForTesting(ResourceId id); - private: struct Resource { Resource(); @@ -254,7 +250,6 @@ private: bool exported; bool markedForDeletion; bool pendingSetPixels; - bool allocated; gfx::Size size; GLenum format; // TODO(skyostil): Use a separate sampler object for filter state. @@ -282,7 +277,6 @@ private: bool transferResource(WebKit::WebGraphicsContext3D*, ResourceId, TransferableResource*); void deleteResourceInternal(ResourceMap::iterator it); - void lazyAllocate(Resource*); OutputSurface* m_outputSurface; ResourceId m_nextId; diff --git a/cc/resource_provider_unittest.cc b/cc/resource_provider_unittest.cc index f57061a..0a737e5 100644 --- a/cc/resource_provider_unittest.cc +++ b/cc/resource_provider_unittest.cc @@ -20,9 +20,6 @@ using namespace WebKit; using testing::Mock; -using testing::StrictMock; -using testing::NiceMock; -using testing::_; namespace cc { namespace { @@ -590,7 +587,6 @@ TEST_P(ResourceProviderTest, ScopedSampler) EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROMIUM, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM)); ResourceProvider::ResourceId id = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny); - resourceProvider->allocateForTesting(id); // Creating a sampler with the default filter should not change any texture // parameters. @@ -644,76 +640,6 @@ TEST_P(ResourceProviderTest, ManagedResource) Mock::VerifyAndClearExpectations(context); } -class AllocationTrackingContext3D : public FakeWebGraphicsContext3D { -public: - MOCK_METHOD9(texImage2D, void(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, - WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Denum format, - WGC3Denum type, const void* pixels)); - MOCK_METHOD9(texSubImage2D, void(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, - WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, - WGC3Denum type, const void* pixels)); - MOCK_METHOD9(asyncTexImage2DCHROMIUM, void(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, - WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Denum format, - WGC3Denum type, const void* pixels)); - MOCK_METHOD9(asyncTexSubImage2DCHROMIUM, void(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, - WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, - WGC3Denum type, const void* pixels)); -}; - -TEST_P(ResourceProviderTest, TextureAllocation) -{ - // Only for GL textures. - if (GetParam() != ResourceProvider::GLTexture) - return; - scoped_ptr<WebKit::WebGraphicsContext3D> mock_context( - static_cast<WebKit::WebGraphicsContext3D*>(new NiceMock<AllocationTrackingContext3D>)); - scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(mock_context.Pass())); - - gfx::Size size(2, 2); - gfx::Vector2d offset(0, 0); - gfx::Rect rect(0, 0, 2, 2); - WGC3Denum format = GL_RGBA; - ResourceProvider::ResourceId id = 0; - uint8_t pixels[16] = {0}; - - AllocationTrackingContext3D* context = static_cast<AllocationTrackingContext3D*>(outputSurface->Context3D()); - scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outputSurface.get())); - - // Lazy allocation. Don't allocate when creating the resource. - EXPECT_CALL(*context, texImage2D(_,_,_,_,_,_,_,_,_)).Times(0); - EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_,_,_,_,_,_,_,_,_)).Times(0); - id = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny); - resourceProvider->deleteResource(id); - Mock::VerifyAndClearExpectations(context); - - // Do allocate when we set the pixels. - EXPECT_CALL(*context, texImage2D(_,_,_,2,2,_,_,_,_)).Times(1); - EXPECT_CALL(*context, texSubImage2D(_,_,_,_,2,2,_,_,_)).Times(1); - id = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny); - resourceProvider->setPixels(id, pixels, rect, rect, offset); - resourceProvider->deleteResource(id); - Mock::VerifyAndClearExpectations(context); - - // Same for setPixelsFromBuffer - EXPECT_CALL(*context, texImage2D(_,_,_,2,2,_,_,_,_)).Times(1); - EXPECT_CALL(*context, texSubImage2D(_,_,_,_,2,2,_,_,_)).Times(1); - id = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny); - resourceProvider->acquirePixelBuffer(id); - resourceProvider->setPixelsFromBuffer(id); - resourceProvider->releasePixelBuffer(id); - resourceProvider->deleteResource(id); - Mock::VerifyAndClearExpectations(context); - - // Same for async version. - EXPECT_CALL(*context, asyncTexImage2DCHROMIUM(_,_,_,2,2,_,_,_,_)).Times(1); - id = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny); - resourceProvider->acquirePixelBuffer(id); - resourceProvider->beginSetPixels(id); - resourceProvider->releasePixelBuffer(id); - resourceProvider->deleteResource(id); - Mock::VerifyAndClearExpectations(context); -} - INSTANTIATE_TEST_CASE_P(ResourceProviderTests, ResourceProviderTest, ::testing::Values(ResourceProvider::GLTexture, diff --git a/cc/test/render_pass_test_common.cc b/cc/test/render_pass_test_common.cc index b9cadb2..f44558f 100644 --- a/cc/test/render_pass_test_common.cc +++ b/cc/test/render_pass_test_common.cc @@ -29,7 +29,6 @@ void TestRenderPass::AppendOneOfEveryQuadType( gfx::Size(20, 12), resourceProvider->bestTextureFormat(), ResourceProvider::TextureUsageAny); - resourceProvider->allocateForTesting(texture_resource); scoped_ptr<cc::SharedQuadState> shared_state = cc::SharedQuadState::Create(); shared_state->SetAll(gfx::Transform(), rect, |