Commit 0dd1e567 authored by reveman@google.com's avatar reveman@google.com

cc: Fix tile manager shutdown by aborting all pending uploads.

CHROMIUM_async_pixel_transfers doesn't have a way to abort a pending
upload but deleting texture and query has the same effect.

BUG=173704
NOTRY=true

Review URL: https://codereview.chromium.org/12223050

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181952 0039d316-1c4b-4281-b951-d872f2087c98
parent 8aee03e0
......@@ -48,6 +48,18 @@ static bool isTextureFormatSupportedForStorage(GLenum format)
return (format == GL_RGBA || format == GL_BGRA_EXT);
}
static unsigned createTextureId(WebGraphicsContext3D* context3d)
{
unsigned textureId = 0;
GLC(context3d, textureId = context3d->createTexture());
GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
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));
return textureId;
}
ResourceProvider::Resource::Resource()
: glId(0)
, glPixelBufferId(0)
......@@ -192,17 +204,11 @@ ResourceProvider::ResourceId ResourceProvider::createGLTexture(const gfx::Size&
DCHECK_LE(size.height(), m_maxTextureSize);
DCHECK(m_threadChecker.CalledOnValidThread());
unsigned textureId = 0;
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
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));
// Create and set texture properties. Allocation is delayed until needed.
unsigned textureId = createTextureId(context3d);
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));
......@@ -1051,6 +1057,32 @@ bool ResourceProvider::didSetPixelsComplete(ResourceId id) {
return true;
}
void ResourceProvider::abortSetPixels(ResourceId id) {
DCHECK(m_threadChecker.CalledOnValidThread());
ResourceMap::iterator it = m_resources.find(id);
CHECK(it != m_resources.end());
Resource* resource = &it->second;
DCHECK(resource->lockedForWrite);
DCHECK(resource->pendingSetPixels);
if (resource->glId) {
WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
DCHECK(context3d);
DCHECK(resource->glUploadQueryId);
// CHROMIUM_async_pixel_transfers currently doesn't have a way to
// abort an upload. The best we can do is delete the query and
// the texture.
context3d->deleteQueryEXT(resource->glUploadQueryId);
resource->glUploadQueryId = 0;
context3d->deleteTexture(resource->glId);
resource->glId = createTextureId(context3d);
resource->allocated = false;
}
resource->pendingSetPixels = false;
unlockForWrite(id);
}
void ResourceProvider::allocateForTesting(ResourceId id) {
ResourceMap::iterator it = m_resources.find(id);
CHECK(it != m_resources.end());
......
......@@ -244,6 +244,7 @@ public:
// Asynchronously update pixels from acquired pixel buffer.
void beginSetPixels(ResourceId id);
bool didSetPixelsComplete(ResourceId id);
void abortSetPixels(ResourceId id);
// For tests only! This prevents detecting uninitialized reads.
// Use setPixels or lockForWrite to allocate implicitly.
......
......@@ -142,7 +142,7 @@ TileManager::~TileManager() {
// This should finish all pending tasks and release any uninitialized
// resources.
raster_worker_pool_.reset();
CheckForCompletedTileUploads();
AbortPendingTileUploads();
DCHECK(tiles_with_pending_set_pixels_.size() == 0);
DCHECK(tiles_.size() == 0);
}
......@@ -373,6 +373,28 @@ void TileManager::CheckForCompletedTileUploads() {
DispatchMoreTasks();
}
void TileManager::AbortPendingTileUploads() {
while (!tiles_with_pending_set_pixels_.empty()) {
Tile* tile = tiles_with_pending_set_pixels_.front();
ManagedTileState& managed_tile_state = tile->managed_state();
DCHECK(managed_tile_state.resource);
resource_pool_->resource_provider()->abortSetPixels(
managed_tile_state.resource->id());
resource_pool_->resource_provider()->releasePixelBuffer(
managed_tile_state.resource->id());
managed_tile_state.resource_is_being_initialized = false;
managed_tile_state.can_be_freed = true;
managed_tile_state.can_use_gpu_memory = false;
FreeResourcesForTile(tile);
bytes_pending_set_pixels_ -= tile->bytes_consumed_if_allocated();
DidTileRasterStateChange(tile, IDLE_STATE);
tiles_with_pending_set_pixels_.pop();
}
}
void TileManager::GetMemoryStats(
size_t* memoryRequiredBytes,
size_t* memoryNiceToHaveBytes,
......
......@@ -105,6 +105,7 @@ class CC_EXPORT TileManager {
void ManageTiles();
void CheckForCompletedTileUploads();
void AbortPendingTileUploads();
scoped_ptr<base::Value> AsValue() const;
void GetMemoryStats(size_t* memoryRequiredBytes,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment