diff options
author | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-20 11:56:59 +0000 |
---|---|---|
committer | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-20 11:56:59 +0000 |
commit | 64436d35be38ab9a9dfd4e9ef956f983f48c34e1 (patch) | |
tree | caf46a80ce5c537b348adc912cdfe51ea702707b | |
parent | 9982806f4cc9e515bffd3bba9f822186338f79e2 (diff) | |
download | chromium_src-64436d35be38ab9a9dfd4e9ef956f983f48c34e1.zip chromium_src-64436d35be38ab9a9dfd4e9ef956f983f48c34e1.tar.gz chromium_src-64436d35be38ab9a9dfd4e9ef956f983f48c34e1.tar.bz2 |
cc: Chromify PrioritizedResource
R=danakj@chromium.org
BUG=none
Review URL: https://chromiumcodereview.appspot.com/12906008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189241 0039d316-1c4b-4281-b951-d872f2087c98
20 files changed, 485 insertions, 468 deletions
diff --git a/cc/layers/nine_patch_layer.cc b/cc/layers/nine_patch_layer.cc index b239222..ae874c0 100644 --- a/cc/layers/nine_patch_layer.cc +++ b/cc/layers/nine_patch_layer.cc @@ -28,7 +28,7 @@ scoped_ptr<LayerImpl> NinePatchLayer::CreateLayerImpl( void NinePatchLayer::SetTexturePriorities( const PriorityCalculator& priority_calc) { - if (resource_ && !resource_->texture()->resourceManager()) { + if (resource_ && !resource_->texture()->resource_manager()) { // Release the resource here, as it is no longer tied to a resource manager. resource_.reset(); if (!bitmap_.isNull()) @@ -38,13 +38,13 @@ void NinePatchLayer::SetTexturePriorities( } if (resource_) { - resource_->texture()->setRequestPriority( + resource_->texture()->set_request_priority( PriorityCalculator::UIPriority(true)); // FIXME: Need to support swizzle in the shader for // !PlatformColor::sameComponentOrder(texture_format) GLenum texture_format = layer_tree_host()->GetRendererCapabilities().best_texture_format; - resource_->texture()->setDimensions( + resource_->texture()->SetDimensions( gfx::Size(bitmap_.width(), bitmap_.height()), texture_format); } } @@ -61,7 +61,7 @@ void NinePatchLayer::Update(ResourceUpdateQueue* queue, RenderingStats* stats) { CreateUpdaterIfNeeded(); - if (resource_ && (bitmap_dirty_ || resource_->texture()->resourceId() == 0)) { + if (resource_ && (bitmap_dirty_ || resource_->texture()->ResourceId() == 0)) { gfx::Rect contentRect(gfx::Point(), gfx::Size(bitmap_.width(), bitmap_.height())); ResourceUpdate upload = ResourceUpdate::Create(resource_->texture(), @@ -107,7 +107,7 @@ void NinePatchLayer::PushPropertiesTo(LayerImpl* layer) { if (resource_) { DCHECK(!bitmap_.isNull()); - layer_impl->SetResourceId(resource_->texture()->resourceId()); + layer_impl->SetResourceId(resource_->texture()->ResourceId()); layer_impl->SetLayout( gfx::Size(bitmap_.width(), bitmap_.height()), image_aperture_); } diff --git a/cc/layers/nine_patch_layer_unittest.cc b/cc/layers/nine_patch_layer_unittest.cc index b8a6047..45de303 100644 --- a/cc/layers/nine_patch_layer_unittest.cc +++ b/cc/layers/nine_patch_layer_unittest.cc @@ -110,8 +110,8 @@ TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap) DebugScopedSetMainThreadBlocked mainThreadBlocked(proxy()); outputSurface = createFakeOutputSurface(); resourceProvider = ResourceProvider::Create(outputSurface.get()); - params.texture->acquireBackingTexture(resourceProvider.get()); - ASSERT_TRUE(params.texture->haveBackingTexture()); + params.texture->AcquireBackingTexture(resourceProvider.get()); + ASSERT_TRUE(params.texture->have_backing_texture()); } // Nothing changed, so no repeated upload. @@ -134,7 +134,7 @@ TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap) // PrioritizedResourceManager clearing layer_tree_host_->contents_texture_manager()->unregisterTexture(params.texture); - EXPECT_EQ(NULL, params.texture->resourceManager()); + EXPECT_EQ(NULL, params.texture->resource_manager()); testLayer->SetTexturePriorities(calculator); ResourceUpdateQueue queue2; testLayer->Update(&queue2, &occlusionTracker, NULL); @@ -142,7 +142,7 @@ TEST_F(NinePatchLayerTest, triggerFullUploadOnceWhenChangingBitmap) EXPECT_EQ(queue2.partialUploadSize(), 0); params = queue2.takeFirstFullUpload(); EXPECT_TRUE(params.texture != NULL); - EXPECT_EQ(params.texture->resourceManager(), layer_tree_host_->contents_texture_manager()); + EXPECT_EQ(params.texture->resource_manager(), layer_tree_host_->contents_texture_manager()); } } // namespace diff --git a/cc/layers/scrollbar_layer.cc b/cc/layers/scrollbar_layer.cc index 1550ad9..4f648e6 100644 --- a/cc/layers/scrollbar_layer.cc +++ b/cc/layers/scrollbar_layer.cc @@ -115,22 +115,22 @@ void ScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { scrollbar_layer->SetScrollbarData(scrollbar_.get()); scrollbar_layer->SetThumbSize(thumb_size_); - if (back_track_ && back_track_->texture()->haveBackingTexture()) { + if (back_track_ && back_track_->texture()->have_backing_texture()) { scrollbar_layer->set_back_track_resource_id( - back_track_->texture()->resourceId()); + back_track_->texture()->ResourceId()); } else { scrollbar_layer->set_back_track_resource_id(0); } - if (fore_track_ && fore_track_->texture()->haveBackingTexture()) { + if (fore_track_ && fore_track_->texture()->have_backing_texture()) { scrollbar_layer->set_fore_track_resource_id( - fore_track_->texture()->resourceId()); + fore_track_->texture()->ResourceId()); } else { scrollbar_layer->set_fore_track_resource_id(0); } - if (thumb_ && thumb_->texture()->haveBackingTexture()) - scrollbar_layer->set_thumb_resource_id(thumb_->texture()->resourceId()); + if (thumb_ && thumb_->texture()->have_backing_texture()) + scrollbar_layer->set_thumb_resource_id(thumb_->texture()->ResourceId()); else scrollbar_layer->set_thumb_resource_id(0); @@ -317,14 +317,14 @@ void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter, // Skip painting and uploading if there are no invalidations and // we already have valid texture data. - if (resource->texture()->haveBackingTexture() && + if (resource->texture()->have_backing_texture() && resource->texture()->size() == rect.size() && !is_dirty()) return; // We should always have enough memory for UI. - DCHECK(resource->texture()->canAcquireBackingTexture()); - if (!resource->texture()->canAcquireBackingTexture()) + DCHECK(resource->texture()->can_acquire_backing_texture()); + if (!resource->texture()->can_acquire_backing_texture()) return; // Paint and upload the entire part. @@ -336,7 +336,7 @@ void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter, &painted_opaque_rect, stats); if (!painter->pixels_did_change() && - resource->texture()->haveBackingTexture()) { + resource->texture()->have_backing_texture()) { TRACE_EVENT_INSTANT0("cc", "ScrollbarLayer::updatePart no texture upload needed"); return; @@ -345,7 +345,7 @@ void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter, bool partial_updates_allowed = layer_tree_host()->settings().maxPartialTextureUpdates > 0; if (!partial_updates_allowed) - resource->texture()->returnBackingTexture(); + resource->texture()->ReturnBackingTexture(); gfx::Vector2d dest_offset(0, 0); resource->Update(queue, rect, dest_offset, partial_updates_allowed, stats); @@ -375,21 +375,21 @@ void ScrollbarLayer::SetTexturePriorities( bool draws_to_root = !render_target()->parent(); if (back_track_) { - back_track_->texture()->setDimensions(content_bounds(), texture_format_); - back_track_->texture()->setRequestPriority( + back_track_->texture()->SetDimensions(content_bounds(), texture_format_); + back_track_->texture()->set_request_priority( PriorityCalculator::UIPriority(draws_to_root)); } if (fore_track_) { - fore_track_->texture()->setDimensions(content_bounds(), texture_format_); - fore_track_->texture()->setRequestPriority( + fore_track_->texture()->SetDimensions(content_bounds(), texture_format_); + fore_track_->texture()->set_request_priority( PriorityCalculator::UIPriority(draws_to_root)); } if (thumb_) { gfx::Rect thumb_layer_rect = geometry_->thumbRect(scrollbar_.get()); gfx::Size thumb_size = ScrollbarLayerRectToContentRect(thumb_layer_rect).size(); - thumb_->texture()->setDimensions(thumb_size, texture_format_); - thumb_->texture()->setRequestPriority( + thumb_->texture()->SetDimensions(thumb_size, texture_format_); + thumb_->texture()->set_request_priority( PriorityCalculator::UIPriority(draws_to_root)); } } diff --git a/cc/layers/tiled_layer.cc b/cc/layers/tiled_layer.cc index e64222b..0d309ec 100644 --- a/cc/layers/tiled_layer.cc +++ b/cc/layers/tiled_layer.cc @@ -197,7 +197,7 @@ void TiledLayer::PushPropertiesTo(LayerImpl* layer) { if (!tile) continue; - if (!tile->managed_resource()->haveBackingTexture()) { + if (!tile->managed_resource()->have_backing_texture()) { // Evicted tiles get deleted from both layers invalid_tiles.push_back(tile); continue; @@ -212,9 +212,9 @@ void TiledLayer::PushPropertiesTo(LayerImpl* layer) { tiled_layer->PushTileProperties( i, j, - tile->managed_resource()->resourceId(), + tile->managed_resource()->ResourceId(), tile->opaque_rect(), - tile->managed_resource()->contentsSwizzled()); + tile->managed_resource()->contents_swizzled()); } for (std::vector<UpdatableTile*>::const_iterator iter = invalid_tiles.begin(); iter != invalid_tiles.end(); @@ -248,7 +248,7 @@ void TiledLayer::SetLayerTreeHost(LayerTreeHost* host) { // FIXME: This should not ever be null. if (!tile) continue; - tile->managed_resource()->setTextureManager( + tile->managed_resource()->SetTextureManager( host->contents_texture_manager()); } } @@ -264,7 +264,7 @@ UpdatableTile* TiledLayer::CreateTile(int i, int j) { scoped_ptr<UpdatableTile> tile( UpdatableTile::Create(Updater()->CreateResource(ResourceManager()))); - tile->managed_resource()->setDimensions(tiler_->tile_size(), texture_format_); + tile->managed_resource()->SetDimensions(tiler_->tile_size(), texture_format_); UpdatableTile* added_tile = tile.get(); tiler_->AddTile(tile.PassAs<LayerTilingData::Tile>(), i, j); @@ -305,7 +305,7 @@ void TiledLayer::InvalidateContentRect(gfx::Rect content_rect) { // Returns true if tile is dirty and only part of it needs to be updated. bool TiledLayer::TileOnlyNeedsPartialUpdate(UpdatableTile* tile) { return !tile->dirty_rect.Contains(tiler_->TileRect(tile)) && - tile->managed_resource()->haveBackingTexture(); + tile->managed_resource()->have_backing_texture(); } bool TiledLayer::UpdateTiles(int left, @@ -376,7 +376,7 @@ void TiledLayer::MarkOcclusionsAndRequestTextures( tile->occluded = true; occluded_tile_count++; } else { - succeeded &= tile->managed_resource()->requestLate(); + succeeded &= tile->managed_resource()->RequestLate(); } } } @@ -401,7 +401,7 @@ bool TiledLayer::HaveTexturesForTiles(int left, continue; // Ensure the entire tile is dirty if we don't have the texture. - if (!tile->managed_resource()->haveBackingTexture()) + if (!tile->managed_resource()->have_backing_texture()) tile->dirty_rect = tiler_->TileRect(tile); // If using occlusion and the visible region of the tile is occluded, @@ -409,7 +409,7 @@ bool TiledLayer::HaveTexturesForTiles(int left, if (tile->occluded && !ignore_occlusions) continue; - if (!tile->managed_resource()->canAcquireBackingTexture()) + if (!tile->managed_resource()->can_acquire_backing_texture()) return false; } } @@ -445,7 +445,7 @@ gfx::Rect TiledLayer::MarkTilesForUpdate(int left, tile->partial_update = true; } else { tile->dirty_rect = tiler_->TileRect(tile); - tile->managed_resource()->returnBackingTexture(); + tile->managed_resource()->ReturnBackingTexture(); } } @@ -597,7 +597,7 @@ void SetPriorityForTexture(gfx::Rect visible_rect, } if (priority != PriorityCalculator::LowestPriority()) - texture->setRequestPriority(priority); + texture->set_request_priority(priority); } } // namespace @@ -861,9 +861,10 @@ bool TiledLayer::NeedsIdlePaint() { continue; bool updated = !tile->update_rect.IsEmpty(); - bool can_acquire = tile->managed_resource()->canAcquireBackingTexture(); + bool can_acquire = + tile->managed_resource()->can_acquire_backing_texture(); bool dirty = - tile->is_dirty() || !tile->managed_resource()->haveBackingTexture(); + tile->is_dirty() || !tile->managed_resource()->have_backing_texture(); if (!updated && can_acquire && dirty) return true; } diff --git a/cc/resources/bitmap_content_layer_updater.cc b/cc/resources/bitmap_content_layer_updater.cc index a6d2a7c..8a65e9e 100644 --- a/cc/resources/bitmap_content_layer_updater.cc +++ b/cc/resources/bitmap_content_layer_updater.cc @@ -43,7 +43,7 @@ BitmapContentLayerUpdater::~BitmapContentLayerUpdater() {} scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::CreateResource( PrioritizedResourceManager* manager) { return scoped_ptr<LayerUpdater::Resource>( - new Resource(this, PrioritizedResource::create(manager))); + new Resource(this, PrioritizedResource::Create(manager))); } void BitmapContentLayerUpdater::PrepareToUpdate( diff --git a/cc/resources/bitmap_skpicture_content_layer_updater.cc b/cc/resources/bitmap_skpicture_content_layer_updater.cc index 9931e11..e2fdc04 100644 --- a/cc/resources/bitmap_skpicture_content_layer_updater.cc +++ b/cc/resources/bitmap_skpicture_content_layer_updater.cc @@ -62,7 +62,7 @@ scoped_ptr<LayerUpdater::Resource> BitmapSkPictureContentLayerUpdater::CreateResource( PrioritizedResourceManager* manager) { return scoped_ptr<LayerUpdater::Resource>( - new Resource(this, PrioritizedResource::create(manager))); + new Resource(this, PrioritizedResource::Create(manager))); } void BitmapSkPictureContentLayerUpdater::PaintContentsRect( diff --git a/cc/resources/image_layer_updater.cc b/cc/resources/image_layer_updater.cc index e76d5b0..5390d90 100644 --- a/cc/resources/image_layer_updater.cc +++ b/cc/resources/image_layer_updater.cc @@ -31,7 +31,7 @@ scoped_refptr<ImageLayerUpdater> ImageLayerUpdater::Create() { scoped_ptr<LayerUpdater::Resource> ImageLayerUpdater::CreateResource( PrioritizedResourceManager* manager) { return scoped_ptr<LayerUpdater::Resource>( - new Resource(this, PrioritizedResource::create(manager))); + new Resource(this, PrioritizedResource::Create(manager))); } void ImageLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, diff --git a/cc/resources/prioritized_resource.cc b/cc/resources/prioritized_resource.cc index ac1be69..4cdb0bf 100644 --- a/cc/resources/prioritized_resource.cc +++ b/cc/resources/prioritized_resource.cc @@ -13,198 +13,194 @@ namespace cc { -PrioritizedResource::PrioritizedResource(PrioritizedResourceManager* manager, gfx::Size size, GLenum format) - : m_size(size) - , m_format(format) - , m_bytes(0) - , m_contentsSwizzled(false) - , m_priority(PriorityCalculator::LowestPriority()) - , m_isAbovePriorityCutoff(false) - , m_isSelfManaged(false) - , m_backing(0) - , m_manager(0) -{ - // m_manager is set in registerTexture() so validity can be checked. - DCHECK(format || size.IsEmpty()); - if (format) - m_bytes = Resource::MemorySizeBytes(size, format); - if (manager) - manager->registerTexture(this); -} - -PrioritizedResource::~PrioritizedResource() -{ - if (m_manager) - m_manager->unregisterTexture(this); -} - -void PrioritizedResource::setTextureManager(PrioritizedResourceManager* manager) -{ - if (m_manager == manager) - return; - if (m_manager) - m_manager->unregisterTexture(this); - if (manager) - manager->registerTexture(this); -} - -void PrioritizedResource::setDimensions(gfx::Size size, GLenum format) -{ - if (m_format != format || m_size != size) { - m_isAbovePriorityCutoff = false; - m_format = format; - m_size = size; - m_bytes = Resource::MemorySizeBytes(size, format); - DCHECK(m_manager || !m_backing); - if (m_manager) - m_manager->returnBackingTexture(this); - } -} - -bool PrioritizedResource::requestLate() -{ - if (!m_manager) - return false; - return m_manager->requestLate(this); -} - -bool PrioritizedResource::backingResourceWasEvicted() const -{ - return m_backing ? m_backing->resourceHasBeenDeleted() : false; -} - -void PrioritizedResource::acquireBackingTexture(ResourceProvider* resourceProvider) -{ - DCHECK(m_isAbovePriorityCutoff); - if (m_isAbovePriorityCutoff) - m_manager->acquireBackingTextureIfNeeded(this, resourceProvider); -} - -ResourceProvider::ResourceId PrioritizedResource::resourceId() const -{ - if (m_backing) - return m_backing->id(); - return 0; -} - -void PrioritizedResource::setPixels(ResourceProvider* resourceProvider, - const uint8_t* image, const gfx::Rect& imageRect, - const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset) -{ - DCHECK(m_isAbovePriorityCutoff); - if (m_isAbovePriorityCutoff) - acquireBackingTexture(resourceProvider); - DCHECK(m_backing); - resourceProvider->SetPixels(resourceId(), image, imageRect, sourceRect, destOffset); - - // The component order may be bgra if we uploaded bgra pixels to rgba - // texture. Mark contents as swizzled if image component order is - // different than texture format. - m_contentsSwizzled = !PlatformColor::SameComponentOrder(m_format); -} - -void PrioritizedResource::link(Backing* backing) -{ - DCHECK(backing); - DCHECK(!backing->m_owner); - DCHECK(!m_backing); - - m_backing = backing; - m_backing->m_owner = this; -} - -void PrioritizedResource::unlink() -{ - DCHECK(m_backing); - DCHECK(m_backing->m_owner == this); - - m_backing->m_owner = 0; - m_backing = 0; -} - -void PrioritizedResource::setToSelfManagedMemoryPlaceholder(size_t bytes) -{ - setDimensions(gfx::Size(), GL_RGBA); - setIsSelfManaged(true); - m_bytes = bytes; -} +PrioritizedResource::PrioritizedResource(PrioritizedResourceManager* manager, + gfx::Size size, + GLenum format) + : size_(size), + format_(format), + bytes_(0), + contents_swizzled_(false), + priority_(PriorityCalculator::LowestPriority()), + is_above_priority_cutoff_(false), + is_self_managed_(false), + backing_(NULL), + manager_(NULL) { + // manager_ is set in RegisterTexture() so validity can be checked. + DCHECK(format || size.IsEmpty()); + if (format) + bytes_ = Resource::MemorySizeBytes(size, format); + if (manager) + manager->registerTexture(this); +} + +PrioritizedResource::~PrioritizedResource() { + if (manager_) + manager_->unregisterTexture(this); +} + +void PrioritizedResource::SetTextureManager( + PrioritizedResourceManager* manager) { + if (manager_ == manager) + return; + if (manager_) + manager_->unregisterTexture(this); + if (manager) + manager->registerTexture(this); +} + +void PrioritizedResource::SetDimensions(gfx::Size size, GLenum format) { + if (format_ != format || size_ != size) { + is_above_priority_cutoff_ = false; + format_ = format; + size_ = size; + bytes_ = Resource::MemorySizeBytes(size, format); + DCHECK(manager_ || !backing_); + if (manager_) + manager_->returnBackingTexture(this); + } +} + +bool PrioritizedResource::RequestLate() { + if (!manager_) + return false; + return manager_->requestLate(this); +} + +bool PrioritizedResource::BackingResourceWasEvicted() const { + return backing_ ? backing_->ResourceHasBeenDeleted() : false; +} + +void PrioritizedResource::AcquireBackingTexture( + ResourceProvider* resource_provider) { + DCHECK(is_above_priority_cutoff_); + if (is_above_priority_cutoff_) + manager_->acquireBackingTextureIfNeeded(this, resource_provider); +} + +ResourceProvider::ResourceId PrioritizedResource::ResourceId() const { + if (backing_) + return backing_->id(); + return 0; +} + +void PrioritizedResource::SetPixels(ResourceProvider* resource_provider, + const uint8_t* image, + gfx::Rect image_rect, + gfx::Rect source_rect, + gfx::Vector2d dest_offset) { + DCHECK(is_above_priority_cutoff_); + if (is_above_priority_cutoff_) + AcquireBackingTexture(resource_provider); + DCHECK(backing_); + resource_provider->SetPixels( + ResourceId(), image, image_rect, source_rect, dest_offset); + + // The component order may be bgra if we uploaded bgra pixels to rgba + // texture. Mark contents as swizzled if image component order is + // different than texture format. + contents_swizzled_ = !PlatformColor::SameComponentOrder(format_); +} + +void PrioritizedResource::Link(Backing* backing) { + DCHECK(backing); + DCHECK(!backing->owner_); + DCHECK(!backing_); + + backing_ = backing; + backing_->owner_ = this; +} + +void PrioritizedResource::Unlink() { + DCHECK(backing_); + DCHECK(backing_->owner_ == this); + + backing_->owner_ = NULL; + backing_ = NULL; +} + +void PrioritizedResource::SetToSelfManagedMemoryPlaceholder(size_t bytes) { + SetDimensions(gfx::Size(), GL_RGBA); + set_is_self_managed(true); + bytes_ = bytes; +} -PrioritizedResource::Backing::Backing(unsigned id, ResourceProvider* resourceProvider, gfx::Size size, GLenum format) - : Resource(id, size, format) - , m_owner(0) - , m_priorityAtLastPriorityUpdate(PriorityCalculator::LowestPriority()) - , m_wasAbovePriorityCutoffAtLastPriorityUpdate(false) - , m_inDrawingImplTree(false) - , m_resourceHasBeenDeleted(false) +PrioritizedResource::Backing::Backing(unsigned id, + ResourceProvider* resource_provider, + gfx::Size size, + GLenum format) + : Resource(id, size, format), + owner_(NULL), + priority_at_last_priority_update_(PriorityCalculator::LowestPriority()), + was_above_priority_cutoff_at_last_priority_update_(false), + in_drawing_impl_tree_(false), + resource_has_been_deleted_(false) #ifndef NDEBUG - , m_resourceProvider(resourceProvider) + , + resource_provider_(resource_provider) #endif -{ + { } -PrioritizedResource::Backing::~Backing() -{ - DCHECK(!m_owner); - DCHECK(m_resourceHasBeenDeleted); +PrioritizedResource::Backing::~Backing() { + DCHECK(!owner_); + DCHECK(resource_has_been_deleted_); } -void PrioritizedResource::Backing::deleteResource(ResourceProvider* resourceProvider) -{ - DCHECK(!proxy() || proxy()->IsImplThread()); - DCHECK(!m_resourceHasBeenDeleted); +void PrioritizedResource::Backing::DeleteResource( + ResourceProvider* resource_provider) { + DCHECK(!proxy() || proxy()->IsImplThread()); + DCHECK(!resource_has_been_deleted_); #ifndef NDEBUG - DCHECK(resourceProvider == m_resourceProvider); + DCHECK(resource_provider == resource_provider_); #endif - resourceProvider->DeleteResource(id()); - set_id(0); - m_resourceHasBeenDeleted = true; + resource_provider->DeleteResource(id()); + set_id(0); + resource_has_been_deleted_ = true; } -bool PrioritizedResource::Backing::resourceHasBeenDeleted() const -{ - DCHECK(!proxy() || proxy()->IsImplThread()); - return m_resourceHasBeenDeleted; +bool PrioritizedResource::Backing::ResourceHasBeenDeleted() const { + DCHECK(!proxy() || proxy()->IsImplThread()); + return resource_has_been_deleted_; } -bool PrioritizedResource::Backing::canBeRecycled() const -{ - DCHECK(!proxy() || proxy()->IsImplThread()); - return !m_wasAbovePriorityCutoffAtLastPriorityUpdate && !m_inDrawingImplTree; +bool PrioritizedResource::Backing::CanBeRecycled() const { + DCHECK(!proxy() || proxy()->IsImplThread()); + return !was_above_priority_cutoff_at_last_priority_update_ && + !in_drawing_impl_tree_; } -void PrioritizedResource::Backing::updatePriority() -{ - DCHECK(!proxy() || proxy()->IsImplThread() && proxy()->IsMainThreadBlocked()); - if (m_owner) { - m_priorityAtLastPriorityUpdate = m_owner->requestPriority(); - m_wasAbovePriorityCutoffAtLastPriorityUpdate = m_owner->isAbovePriorityCutoff(); - } else { - m_priorityAtLastPriorityUpdate = PriorityCalculator::LowestPriority(); - m_wasAbovePriorityCutoffAtLastPriorityUpdate = false; - } +void PrioritizedResource::Backing::UpdatePriority() { + DCHECK(!proxy() || proxy()->IsImplThread() && proxy()->IsMainThreadBlocked()); + if (owner_) { + priority_at_last_priority_update_ = owner_->request_priority(); + was_above_priority_cutoff_at_last_priority_update_ = + owner_->is_above_priority_cutoff(); + } else { + priority_at_last_priority_update_ = PriorityCalculator::LowestPriority(); + was_above_priority_cutoff_at_last_priority_update_ = false; + } } -void PrioritizedResource::Backing::updateInDrawingImplTree() -{ - DCHECK(!proxy() || proxy()->IsImplThread() && proxy()->IsMainThreadBlocked()); - m_inDrawingImplTree = !!owner(); - if (!m_inDrawingImplTree) - DCHECK_EQ(m_priorityAtLastPriorityUpdate, PriorityCalculator::LowestPriority()); +void PrioritizedResource::Backing::UpdateInDrawingImplTree() { + DCHECK(!proxy() || proxy()->IsImplThread() && proxy()->IsMainThreadBlocked()); + in_drawing_impl_tree_ = !!owner(); + if (!in_drawing_impl_tree_) { + DCHECK_EQ(priority_at_last_priority_update_, + PriorityCalculator::LowestPriority()); + } } -void PrioritizedResource::returnBackingTexture() -{ - DCHECK(m_manager || !m_backing); - if (m_manager) - m_manager->returnBackingTexture(this); +void PrioritizedResource::ReturnBackingTexture() { + DCHECK(manager_ || !backing_); + if (manager_) + manager_->returnBackingTexture(this); } -const Proxy* PrioritizedResource::Backing::proxy() const -{ - if (!m_owner || !m_owner->resourceManager()) - return 0; - return m_owner->resourceManager()->proxyForDebug(); +const Proxy* PrioritizedResource::Backing::proxy() const { + if (!owner_ || !owner_->resource_manager()) + return NULL; + return owner_->resource_manager()->proxyForDebug(); } } // namespace cc diff --git a/cc/resources/prioritized_resource.h b/cc/resources/prioritized_resource.h index 566dce4..22b63de 100644 --- a/cc/resources/prioritized_resource.h +++ b/cc/resources/prioritized_resource.h @@ -23,134 +23,154 @@ class PrioritizedResourceManager; class Proxy; class CC_EXPORT PrioritizedResource { -public: - static scoped_ptr<PrioritizedResource> create(PrioritizedResourceManager* manager, gfx::Size size, GLenum format) - { - return make_scoped_ptr(new PrioritizedResource(manager, size, format)); + public: + static scoped_ptr<PrioritizedResource> + Create(PrioritizedResourceManager* manager, gfx::Size size, GLenum format) { + return make_scoped_ptr(new PrioritizedResource(manager, size, format)); + } + static scoped_ptr<PrioritizedResource> Create( + PrioritizedResourceManager* manager) { + return make_scoped_ptr(new PrioritizedResource(manager, gfx::Size(), 0)); + } + ~PrioritizedResource(); + + // Texture properties. Changing these causes the backing texture to be lost. + // Setting these to the same value is a no-op. + void SetTextureManager(PrioritizedResourceManager* manager); + PrioritizedResourceManager* resource_manager() { return manager_; } + void SetDimensions(gfx::Size size, GLenum format); + GLenum format() const { return format_; } + gfx::Size size() const { return size_; } + size_t bytes() const { return bytes_; } + bool contents_swizzled() const { return contents_swizzled_; } + + // Set priority for the requested texture. + void set_request_priority(int priority) { priority_ = priority; } + int request_priority() const { return priority_; } + + // After PrioritizedResource::PrioritizeTextures() is called, this returns + // if the the request succeeded and this texture can be acquired for use. + bool can_acquire_backing_texture() const { return is_above_priority_cutoff_; } + + // This returns whether we still have a backing texture. This can continue + // to be true even after CanAcquireBackingTexture() becomes false. In this + // case the texture can be used but shouldn't be updated since it will get + // taken away "soon". + bool have_backing_texture() const { return !!backing(); } + + bool BackingResourceWasEvicted() const; + + // If CanAcquireBackingTexture() is true AcquireBackingTexture() will acquire + // a backing texture for use. Call this whenever the texture is actually + // needed. + void AcquireBackingTexture(ResourceProvider* resource_provider); + + // TODO(epenner): Request late is really a hack for when we are totally out of + // memory (all textures are visible) but we can still squeeze into the limit + // by not painting occluded textures. In this case the manager refuses all + // visible textures and RequestLate() will enable CanAcquireBackingTexture() + // on a call-order basis. We might want to just remove this in the future + // (carefully) and just make sure we don't regress OOMs situations. + bool RequestLate(); + + // Update pixels of backing resource from image. This functions will aquire + // the backing if needed. + void SetPixels(ResourceProvider* resource_provider, + const uint8_t* image, + gfx::Rect image_rect, + gfx::Rect source_rect, + gfx::Vector2d dest_offset); + + ResourceProvider::ResourceId ResourceId() const; + + // Self-managed textures are accounted for when prioritizing other textures, + // but they are not allocated/recycled/deleted, so this needs to be done + // externally. CanAcquireBackingTexture() indicates if the texture would have + // been allowed given its priority. + void set_is_self_managed(bool is_self_managed) { + is_self_managed_ = is_self_managed; + } + bool is_self_managed() { return is_self_managed_; } + void SetToSelfManagedMemoryPlaceholder(size_t bytes); + + void ReturnBackingTexture(); + + private: + friend class PrioritizedResourceManager; + friend class PrioritizedResourceTest; + + class Backing : public Resource { + public: + Backing(unsigned id, + ResourceProvider* resource_provider, + gfx::Size size, + GLenum format); + ~Backing(); + void UpdatePriority(); + void UpdateInDrawingImplTree(); + + PrioritizedResource* owner() { return owner_; } + bool CanBeRecycled() const; + int request_priority_at_last_priority_update() const { + return priority_at_last_priority_update_; } - static scoped_ptr<PrioritizedResource> create(PrioritizedResourceManager* manager) - { - return make_scoped_ptr(new PrioritizedResource(manager, gfx::Size(), 0)); + bool was_above_priority_cutoff_at_last_priority_update() const { + return was_above_priority_cutoff_at_last_priority_update_; } - ~PrioritizedResource(); - - // Texture properties. Changing these causes the backing texture to be lost. - // Setting these to the same value is a no-op. - void setTextureManager(PrioritizedResourceManager*); - PrioritizedResourceManager* resourceManager() { return m_manager; } - void setDimensions(gfx::Size, GLenum format); - GLenum format() const { return m_format; } - gfx::Size size() const { return m_size; } - size_t bytes() const { return m_bytes; } - bool contentsSwizzled() const { return m_contentsSwizzled; } - - // Set priority for the requested texture. - void setRequestPriority(int priority) { m_priority = priority; } - int requestPriority() const { return m_priority; } - - // After PrioritizedResource::prioritizeTextures() is called, this returns - // if the the request succeeded and this texture can be acquired for use. - bool canAcquireBackingTexture() const { return m_isAbovePriorityCutoff; } - - // This returns whether we still have a backing texture. This can continue - // to be true even after canAcquireBackingTexture() becomes false. In this - // case the texture can be used but shouldn't be updated since it will get - // taken away "soon". - bool haveBackingTexture() const { return !!backing(); } - - bool backingResourceWasEvicted() const; - - // If canAcquireBackingTexture() is true acquireBackingTexture() will acquire - // a backing texture for use. Call this whenever the texture is actually needed. - void acquireBackingTexture(ResourceProvider*); - - // FIXME: Request late is really a hack for when we are totally out of memory - // (all textures are visible) but we can still squeeze into the limit - // by not painting occluded textures. In this case the manager - // refuses all visible textures and requestLate() will enable - // canAcquireBackingTexture() on a call-order basis. We might want to - // just remove this in the future (carefully) and just make sure we don't - // regress OOMs situations. - bool requestLate(); - - // Update pixels of backing resource from image. This functions will aquire the backing if needed. - void setPixels(ResourceProvider*, const uint8_t* image, const gfx::Rect& imageRect, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset); - - ResourceProvider::ResourceId resourceId() const; - - // Self-managed textures are accounted for when prioritizing other textures, - // but they are not allocated/recycled/deleted, so this needs to be done - // externally. canAcquireBackingTexture() indicates if the texture would have - // been allowed given its priority. - void setIsSelfManaged(bool isSelfManaged) { m_isSelfManaged = isSelfManaged; } - bool isSelfManaged() { return m_isSelfManaged; } - void setToSelfManagedMemoryPlaceholder(size_t bytes); - - void returnBackingTexture(); - -private: - friend class PrioritizedResourceManager; - friend class PrioritizedResourceTest; - - class Backing : public Resource { - public: - Backing(unsigned id, ResourceProvider*, gfx::Size, GLenum format); - ~Backing(); - void updatePriority(); - void updateInDrawingImplTree(); - - PrioritizedResource* owner() { return m_owner; } - bool canBeRecycled() const; - int requestPriorityAtLastPriorityUpdate() const { return m_priorityAtLastPriorityUpdate; } - bool wasAbovePriorityCutoffAtLastPriorityUpdate() const { return m_wasAbovePriorityCutoffAtLastPriorityUpdate; } - bool inDrawingImplTree() const { return m_inDrawingImplTree; } + bool in_drawing_impl_tree() const { return in_drawing_impl_tree_; } - void deleteResource(ResourceProvider*); - bool resourceHasBeenDeleted() const; + void DeleteResource(ResourceProvider* resource_provider); + bool ResourceHasBeenDeleted() const; - private: - const Proxy* proxy() const; + private: + const Proxy* proxy() const; - friend class PrioritizedResource; - friend class PrioritizedResourceManager; - PrioritizedResource* m_owner; - int m_priorityAtLastPriorityUpdate; - bool m_wasAbovePriorityCutoffAtLastPriorityUpdate; + friend class PrioritizedResource; + friend class PrioritizedResourceManager; + PrioritizedResource* owner_; + int priority_at_last_priority_update_; + bool was_above_priority_cutoff_at_last_priority_update_; - // Set if this is currently-drawing impl tree. - bool m_inDrawingImplTree; + // Set if this is currently-drawing impl tree. + bool in_drawing_impl_tree_; - bool m_resourceHasBeenDeleted; + bool resource_has_been_deleted_; #ifndef NDEBUG - ResourceProvider* m_resourceProvider; + ResourceProvider* resource_provider_; #endif - DISALLOW_COPY_AND_ASSIGN(Backing); - }; - - PrioritizedResource(PrioritizedResourceManager*, gfx::Size, GLenum format); - - bool isAbovePriorityCutoff() { return m_isAbovePriorityCutoff; } - void setAbovePriorityCutoff(bool isAbovePriorityCutoff) { m_isAbovePriorityCutoff = isAbovePriorityCutoff; } - void setManagerInternal(PrioritizedResourceManager* manager) { m_manager = manager; } - - Backing* backing() const { return m_backing; } - void link(Backing*); - void unlink(); - - gfx::Size m_size; - GLenum m_format; - size_t m_bytes; - bool m_contentsSwizzled; - - int m_priority; - bool m_isAbovePriorityCutoff; - bool m_isSelfManaged; - - Backing* m_backing; - PrioritizedResourceManager* m_manager; - - DISALLOW_COPY_AND_ASSIGN(PrioritizedResource); + DISALLOW_COPY_AND_ASSIGN(Backing); + }; + + PrioritizedResource(PrioritizedResourceManager* resource_manager, + gfx::Size size, + GLenum format); + + bool is_above_priority_cutoff() { return is_above_priority_cutoff_; } + void set_above_priority_cutoff(bool is_above_priority_cutoff) { + is_above_priority_cutoff_ = is_above_priority_cutoff; + } + void set_manager_internal(PrioritizedResourceManager* manager) { + manager_ = manager; + } + + Backing* backing() const { return backing_; } + void Link(Backing* backing); + void Unlink(); + + gfx::Size size_; + GLenum format_; + size_t bytes_; + bool contents_swizzled_; + + int priority_; + bool is_above_priority_cutoff_; + bool is_self_managed_; + + Backing* backing_; + PrioritizedResourceManager* manager_; + + DISALLOW_COPY_AND_ASSIGN(PrioritizedResource); }; } // namespace cc diff --git a/cc/resources/prioritized_resource_manager.cc b/cc/resources/prioritized_resource_manager.cc index 010968e..403a2a0 100644 --- a/cc/resources/prioritized_resource_manager.cc +++ b/cc/resources/prioritized_resource_manager.cc @@ -71,9 +71,9 @@ void PrioritizedResourceManager::prioritizeTextures() for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); ++it) { PrioritizedResource* texture = (*it); sortedTextures.push_back(texture); - if (PriorityCalculator::priority_is_higher(texture->requestPriority(), PriorityCalculator::AllowVisibleOnlyCutoff())) + if (PriorityCalculator::priority_is_higher(texture->request_priority(), PriorityCalculator::AllowVisibleOnlyCutoff())) m_memoryVisibleBytes += texture->bytes(); - if (PriorityCalculator::priority_is_higher(texture->requestPriority(), PriorityCalculator::AllowVisibleAndNearbyCutoff())) + if (PriorityCalculator::priority_is_higher(texture->request_priority(), PriorityCalculator::AllowVisibleAndNearbyCutoff())) m_memoryVisibleAndNearbyBytes += texture->bytes(); } std::sort(sortedTextures.begin(), sortedTextures.end(), compareTextures); @@ -83,12 +83,12 @@ void PrioritizedResourceManager::prioritizeTextures() m_priorityCutoff = m_externalPriorityCutoff; size_t memoryBytes = 0; for (TextureVector::iterator it = sortedTextures.begin(); it != sortedTextures.end(); ++it) { - if ((*it)->isSelfManaged()) { + if ((*it)->is_self_managed()) { // Account for self-managed memory immediately by reducing the memory // available (since it never gets acquired). size_t newMemoryBytes = memoryBytes + (*it)->bytes(); if (newMemoryBytes > m_memoryAvailableBytes) { - m_priorityCutoff = (*it)->requestPriority(); + m_priorityCutoff = (*it)->request_priority(); m_memoryAvailableBytes = memoryBytes; break; } @@ -96,7 +96,7 @@ void PrioritizedResourceManager::prioritizeTextures() } else { size_t newMemoryBytes = memoryBytes + (*it)->bytes(); if (newMemoryBytes > m_memoryAvailableBytes) { - m_priorityCutoff = (*it)->requestPriority(); + m_priorityCutoff = (*it)->request_priority(); break; } memoryBytes = newMemoryBytes; @@ -106,9 +106,9 @@ void PrioritizedResourceManager::prioritizeTextures() // Disallow any textures with priority below the external cutoff to have backings. for (TextureVector::iterator it = sortedTextures.begin(); it != sortedTextures.end(); ++it) { PrioritizedResource* texture = (*it); - if (!PriorityCalculator::priority_is_higher(texture->requestPriority(), m_externalPriorityCutoff) && - texture->haveBackingTexture()) - texture->unlink(); + if (!PriorityCalculator::priority_is_higher(texture->request_priority(), m_externalPriorityCutoff) && + texture->have_backing_texture()) + texture->Unlink(); } // Only allow textures if they are higher than the cutoff. All textures @@ -116,9 +116,9 @@ void PrioritizedResourceManager::prioritizeTextures() // being partially allowed randomly. m_memoryAboveCutoffBytes = 0; for (TextureVector::iterator it = sortedTextures.begin(); it != sortedTextures.end(); ++it) { - bool isAbovePriorityCutoff = PriorityCalculator::priority_is_higher((*it)->requestPriority(), m_priorityCutoff); - (*it)->setAbovePriorityCutoff(isAbovePriorityCutoff); - if (isAbovePriorityCutoff && !(*it)->isSelfManaged()) + bool is_above_priority_cutoff = PriorityCalculator::priority_is_higher((*it)->request_priority(), m_priorityCutoff); + (*it)->set_above_priority_cutoff(is_above_priority_cutoff); + if (is_above_priority_cutoff && !(*it)->is_self_managed()) m_memoryAboveCutoffBytes += (*it)->bytes(); } sortedTextures.clear(); @@ -134,7 +134,7 @@ void PrioritizedResourceManager::pushTexturePrioritiesToBackings() assertInvariants(); for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) - (*it)->updatePriority(); + (*it)->UpdatePriority(); sortBackings(); assertInvariants(); @@ -151,7 +151,7 @@ void PrioritizedResourceManager::updateBackingsInDrawingImplTree() assertInvariants(); for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { PrioritizedResource::Backing* backing = (*it); - backing->updateInDrawingImplTree(); + backing->UpdateInDrawingImplTree(); } sortBackings(); assertInvariants(); @@ -175,7 +175,7 @@ void PrioritizedResourceManager::clearPriorities() // PriorityCalculator::lowestPriority() once we have priorities // for all textures (we can't currently calculate distances for // off-screen textures). - (*it)->setRequestPriority(PriorityCalculator::LingeringPriority((*it)->requestPriority())); + (*it)->set_request_priority(PriorityCalculator::LingeringPriority((*it)->request_priority())); } } @@ -184,15 +184,15 @@ bool PrioritizedResourceManager::requestLate(PrioritizedResource* texture) DCHECK(m_proxy->IsMainThread()); // This is already above cutoff, so don't double count it's memory below. - if (texture->isAbovePriorityCutoff()) + if (texture->is_above_priority_cutoff()) return true; // Allow textures that have priority equal to the cutoff, but not strictly lower. - if (PriorityCalculator::priority_is_lower(texture->requestPriority(), m_priorityCutoff)) + if (PriorityCalculator::priority_is_lower(texture->request_priority(), m_priorityCutoff)) return false; // Disallow textures that do not have a priority strictly higher than the external cutoff. - if (!PriorityCalculator::priority_is_higher(texture->requestPriority(), m_externalPriorityCutoff)) + if (!PriorityCalculator::priority_is_higher(texture->request_priority(), m_externalPriorityCutoff)) return false; size_t newMemoryBytes = m_memoryAboveCutoffBytes + texture->bytes(); @@ -200,16 +200,16 @@ bool PrioritizedResourceManager::requestLate(PrioritizedResource* texture) return false; m_memoryAboveCutoffBytes = newMemoryBytes; - texture->setAbovePriorityCutoff(true); + texture->set_above_priority_cutoff(true); return true; } void PrioritizedResourceManager::acquireBackingTextureIfNeeded(PrioritizedResource* texture, ResourceProvider* resourceProvider) { DCHECK(m_proxy->IsImplThread() && m_proxy->IsMainThreadBlocked()); - DCHECK(!texture->isSelfManaged()); - DCHECK(texture->isAbovePriorityCutoff()); - if (texture->backing() || !texture->isAbovePriorityCutoff()) + DCHECK(!texture->is_self_managed()); + DCHECK(texture->is_above_priority_cutoff()); + if (texture->backing() || !texture->is_above_priority_cutoff()) return; // Find a backing below, by either recycling or allocating. @@ -217,7 +217,7 @@ void PrioritizedResourceManager::acquireBackingTextureIfNeeded(PrioritizedResour // First try to recycle for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { - if (!(*it)->canBeRecycled()) + if (!(*it)->CanBeRecycled()) break; if (resourceProvider->InUseByConsumer((*it)->id())) continue; @@ -241,13 +241,13 @@ void PrioritizedResourceManager::acquireBackingTextureIfNeeded(PrioritizedResour // Move the used backing to the end of the eviction list, and note that // the tail is not sorted. if (backing->owner()) - backing->owner()->unlink(); - texture->link(backing); + backing->owner()->Unlink(); + texture->Link(backing); m_backings.push_back(backing); m_backingsTailNotSorted = true; // Update the backing's priority from its new owner. - backing->updatePriority(); + backing->UpdatePriority(); } bool PrioritizedResourceManager::evictBackingsToReduceMemory(size_t limitBytes, @@ -267,12 +267,12 @@ bool PrioritizedResourceManager::evictBackingsToReduceMemory(size_t limitBytes, while (m_backings.size() > 0) { PrioritizedResource::Backing* backing = m_backings.front(); if (memoryUseBytes() <= limitBytes && - PriorityCalculator::priority_is_higher(backing->requestPriorityAtLastPriorityUpdate(), priorityCutoff)) + PriorityCalculator::priority_is_higher(backing->request_priority_at_last_priority_update(), priorityCutoff)) break; - if (evictionPolicy == EvictOnlyRecyclable && !backing->canBeRecycled()) + if (evictionPolicy == EvictOnlyRecyclable && !backing->CanBeRecycled()) break; if (unlinkPolicy == UnlinkBackings && backing->owner()) - backing->owner()->unlink(); + backing->owner()->Unlink(); evictFirstBackingResource(resourceProvider); } return true; @@ -360,7 +360,7 @@ void PrioritizedResourceManager::unlinkAndClearEvictedBackings() for (BackingList::const_iterator it = m_evictedBackings.begin(); it != m_evictedBackings.end(); ++it) { PrioritizedResource::Backing* backing = (*it); if (backing->owner()) - backing->owner()->unlink(); + backing->owner()->Unlink(); delete backing; } m_evictedBackings.clear(); @@ -381,11 +381,11 @@ void PrioritizedResourceManager::registerTexture(PrioritizedResource* texture) { DCHECK(m_proxy->IsMainThread()); DCHECK(texture); - DCHECK(!texture->resourceManager()); + DCHECK(!texture->resource_manager()); DCHECK(!texture->backing()); DCHECK(!ContainsKey(m_textures, texture)); - texture->setManagerInternal(this); + texture->set_manager_internal(this); m_textures.insert(texture); } @@ -397,16 +397,16 @@ void PrioritizedResourceManager::unregisterTexture(PrioritizedResource* texture) DCHECK(ContainsKey(m_textures, texture)); returnBackingTexture(texture); - texture->setManagerInternal(0); + texture->set_manager_internal(0); m_textures.erase(texture); - texture->setAbovePriorityCutoff(false); + texture->set_above_priority_cutoff(false); } void PrioritizedResourceManager::returnBackingTexture(PrioritizedResource* texture) { DCHECK(m_proxy->IsMainThread() || (m_proxy->IsImplThread() && m_proxy->IsMainThreadBlocked())); if (texture->backing()) - texture->unlink(); + texture->Unlink(); } PrioritizedResource::Backing* PrioritizedResourceManager::createBacking(gfx::Size size, GLenum format, ResourceProvider* resourceProvider) @@ -430,7 +430,7 @@ void PrioritizedResourceManager::evictFirstBackingResource(ResourceProvider* res // delete the backing structure and its resource in two steps. This is because // we can delete the resource while the main thread is running, but we cannot // unlink backings while the main thread is running. - backing->deleteResource(resourceProvider); + backing->DeleteResource(resourceProvider); m_memoryUseBytes -= backing->bytes(); m_backings.pop_front(); base::AutoLock scoped_lock(m_evictedBackingsLock); @@ -458,7 +458,7 @@ void PrioritizedResourceManager::assertInvariants() PrioritizedResource::Backing* backing = texture->backing(); base::AutoLock scoped_lock(m_evictedBackingsLock); if (backing) { - if (backing->resourceHasBeenDeleted()) { + if (backing->ResourceHasBeenDeleted()) { DCHECK(std::find(m_backings.begin(), m_backings.end(), backing) == m_backings.end()); DCHECK(std::find(m_evictedBackings.begin(), m_evictedBackings.end(), backing) != m_evictedBackings.end()); } else { @@ -476,14 +476,14 @@ void PrioritizedResourceManager::assertInvariants() PrioritizedResource::Backing* previous_backing = NULL; for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { PrioritizedResource::Backing* backing = *it; - if (previous_backing && (!m_backingsTailNotSorted || !backing->wasAbovePriorityCutoffAtLastPriorityUpdate())) + if (previous_backing && (!m_backingsTailNotSorted || !backing->was_above_priority_cutoff_at_last_priority_update())) DCHECK(compareBackings(previous_backing, backing)); - if (!backing->canBeRecycled()) + if (!backing->CanBeRecycled()) reachedUnrecyclable = true; if (reachedUnrecyclable) - DCHECK(!backing->canBeRecycled()); + DCHECK(!backing->CanBeRecycled()); else - DCHECK(backing->canBeRecycled()); + DCHECK(backing->CanBeRecycled()); previous_backing = backing; } #endif diff --git a/cc/resources/prioritized_resource_manager.h b/cc/resources/prioritized_resource_manager.h index fb68545..33914ca 100644 --- a/cc/resources/prioritized_resource_manager.h +++ b/cc/resources/prioritized_resource_manager.h @@ -134,26 +134,26 @@ private: // Compare textures. Highest priority first. static inline bool compareTextures(PrioritizedResource* a, PrioritizedResource* b) { - if (a->requestPriority() == b->requestPriority()) + if (a->request_priority() == b->request_priority()) return a < b; - return PriorityCalculator::priority_is_higher(a->requestPriority(), b->requestPriority()); + return PriorityCalculator::priority_is_higher(a->request_priority(), b->request_priority()); } // Compare backings. Lowest priority first. static inline bool compareBackings(PrioritizedResource::Backing* a, PrioritizedResource::Backing* b) { // Make textures that can be recycled appear first - if (a->canBeRecycled() != b->canBeRecycled()) - return (a->canBeRecycled() > b->canBeRecycled()); + if (a->CanBeRecycled() != b->CanBeRecycled()) + return (a->CanBeRecycled() > b->CanBeRecycled()); // Then sort by being above or below the priority cutoff. - if (a->wasAbovePriorityCutoffAtLastPriorityUpdate() != b->wasAbovePriorityCutoffAtLastPriorityUpdate()) - return (a->wasAbovePriorityCutoffAtLastPriorityUpdate() < b->wasAbovePriorityCutoffAtLastPriorityUpdate()); + if (a->was_above_priority_cutoff_at_last_priority_update() != b->was_above_priority_cutoff_at_last_priority_update()) + return (a->was_above_priority_cutoff_at_last_priority_update() < b->was_above_priority_cutoff_at_last_priority_update()); // Then sort by priority (note that backings that no longer have owners will // always have the lowest priority) - if (a->requestPriorityAtLastPriorityUpdate() != b->requestPriorityAtLastPriorityUpdate()) - return PriorityCalculator::priority_is_lower(a->requestPriorityAtLastPriorityUpdate(), b->requestPriorityAtLastPriorityUpdate()); + if (a->request_priority_at_last_priority_update() != b->request_priority_at_last_priority_update()) + return PriorityCalculator::priority_is_lower(a->request_priority_at_last_priority_update(), b->request_priority_at_last_priority_update()); // Finally sort by being in the impl tree versus being completely unreferenced - if (a->inDrawingImplTree() != b->inDrawingImplTree()) - return (a->inDrawingImplTree() < b->inDrawingImplTree()); + if (a->in_drawing_impl_tree() != b->in_drawing_impl_tree()) + return (a->in_drawing_impl_tree() < b->in_drawing_impl_tree()); return a < b; } diff --git a/cc/resources/prioritized_resource_unittest.cc b/cc/resources/prioritized_resource_unittest.cc index 0d11615..8fe3736 100644 --- a/cc/resources/prioritized_resource_unittest.cc +++ b/cc/resources/prioritized_resource_unittest.cc @@ -46,14 +46,14 @@ public: bool validateTexture(scoped_ptr<PrioritizedResource>& texture, bool requestLate) { - resourceManagerAssertInvariants(texture->resourceManager()); + resourceManagerAssertInvariants(texture->resource_manager()); if (requestLate) - texture->requestLate(); - resourceManagerAssertInvariants(texture->resourceManager()); + texture->RequestLate(); + resourceManagerAssertInvariants(texture->resource_manager()); DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy); - bool success = texture->canAcquireBackingTexture(); + bool success = texture->can_acquire_backing_texture(); if (success) - texture->acquireBackingTexture(resourceProvider()); + texture->AcquireBackingTexture(resourceProvider()); return success; } @@ -84,7 +84,7 @@ public: bool textureBackingIsAbovePriorityCutoff(PrioritizedResource* texture) { - return texture->m_backing->wasAbovePriorityCutoffAtLastPriorityUpdate(); + return texture->backing()->was_above_priority_cutoff_at_last_priority_update(); } size_t evictedBackingCount(PrioritizedResourceManager* resourceManager) @@ -115,7 +115,7 @@ TEST_F(PrioritizedResourceTest, requestTextureExceedingMaxLimit) // Set decreasing priorities for (size_t i = 0; i < maxTextures*2; ++i) - textures[i]->setRequestPriority(100 + i); + textures[i]->set_request_priority(100 + i); // Only lower half should be available. prioritizeTexturesAndBackings(resourceManager.get()); @@ -126,7 +126,7 @@ TEST_F(PrioritizedResourceTest, requestTextureExceedingMaxLimit) // Set increasing priorities for (size_t i = 0; i < maxTextures*2; ++i) - textures[i]->setRequestPriority(100 - i); + textures[i]->set_request_priority(100 - i); // Only upper half should be available. prioritizeTexturesAndBackings(resourceManager.get()); @@ -151,7 +151,7 @@ TEST_F(PrioritizedResourceTest, changeMemoryLimits) for (size_t i = 0; i < maxTextures; ++i) textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); for (size_t i = 0; i < maxTextures; ++i) - textures[i]->setRequestPriority(100 + i); + textures[i]->set_request_priority(100 + i); // Set max limit to 8 textures resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(8)); @@ -205,7 +205,7 @@ TEST_F(PrioritizedResourceTest, changePriorityCutoff) for (size_t i = 0; i < maxTextures; ++i) textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); for (size_t i = 0; i < maxTextures; ++i) - textures[i]->setRequestPriority(100 + i); + textures[i]->set_request_priority(100 + i); // Set the cutoff to drop two textures. Try to requestLate on all textures, and // make sure that requestLate doesn't work on a texture with equal priority to @@ -274,7 +274,7 @@ TEST_F(PrioritizedResourceTest, resourceManagerPartialUpdateTextures) } for (size_t i = 0; i < numTextures; ++i) - textures[i]->setRequestPriority(200 + i); + textures[i]->set_request_priority(200 + i); prioritizeTexturesAndBackings(resourceManager.get()); // Allocate textures which are currently high priority. @@ -283,13 +283,13 @@ TEST_F(PrioritizedResourceTest, resourceManagerPartialUpdateTextures) EXPECT_TRUE(validateTexture(textures[2], false)); EXPECT_TRUE(validateTexture(textures[3], false)); - EXPECT_TRUE(textures[0]->haveBackingTexture()); - EXPECT_TRUE(textures[1]->haveBackingTexture()); - EXPECT_TRUE(textures[2]->haveBackingTexture()); - EXPECT_TRUE(textures[3]->haveBackingTexture()); + EXPECT_TRUE(textures[0]->have_backing_texture()); + EXPECT_TRUE(textures[1]->have_backing_texture()); + EXPECT_TRUE(textures[2]->have_backing_texture()); + EXPECT_TRUE(textures[3]->have_backing_texture()); for (size_t i = 0; i < numTextures; ++i) - moreTextures[i]->setRequestPriority(100 + i); + moreTextures[i]->set_request_priority(100 + i); prioritizeTexturesAndBackings(resourceManager.get()); // Textures are now below cutoff. @@ -299,10 +299,10 @@ TEST_F(PrioritizedResourceTest, resourceManagerPartialUpdateTextures) EXPECT_FALSE(validateTexture(textures[3], false)); // But they are still valid to use. - EXPECT_TRUE(textures[0]->haveBackingTexture()); - EXPECT_TRUE(textures[1]->haveBackingTexture()); - EXPECT_TRUE(textures[2]->haveBackingTexture()); - EXPECT_TRUE(textures[3]->haveBackingTexture()); + EXPECT_TRUE(textures[0]->have_backing_texture()); + EXPECT_TRUE(textures[1]->have_backing_texture()); + EXPECT_TRUE(textures[2]->have_backing_texture()); + EXPECT_TRUE(textures[3]->have_backing_texture()); // Higher priority textures are finally needed. EXPECT_TRUE(validateTexture(moreTextures[0], false)); @@ -311,10 +311,10 @@ TEST_F(PrioritizedResourceTest, resourceManagerPartialUpdateTextures) EXPECT_TRUE(validateTexture(moreTextures[3], false)); // Lower priority have been fully evicted. - EXPECT_FALSE(textures[0]->haveBackingTexture()); - EXPECT_FALSE(textures[1]->haveBackingTexture()); - EXPECT_FALSE(textures[2]->haveBackingTexture()); - EXPECT_FALSE(textures[3]->haveBackingTexture()); + EXPECT_FALSE(textures[0]->have_backing_texture()); + EXPECT_FALSE(textures[1]->have_backing_texture()); + EXPECT_FALSE(textures[2]->have_backing_texture()); + EXPECT_FALSE(textures[3]->have_backing_texture()); DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy); resourceManager->clearAllMemory(resourceProvider()); @@ -331,9 +331,9 @@ TEST_F(PrioritizedResourceTest, resourceManagerPrioritiesAreEqual) // All 16 textures have the same priority except 2 higher priority. for (size_t i = 0; i < maxTextures; ++i) - textures[i]->setRequestPriority(100); - textures[0]->setRequestPriority(99); - textures[1]->setRequestPriority(99); + textures[i]->set_request_priority(100); + textures[0]->set_request_priority(99); + textures[1]->set_request_priority(99); // Set max limit to 8 textures resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(8)); @@ -366,14 +366,14 @@ TEST_F(PrioritizedResourceTest, resourceManagerDestroyedFirst) scoped_ptr<PrioritizedResource> texture = resourceManager->createTexture(m_textureSize, m_textureFormat); // Texture is initially invalid, but it will become available. - EXPECT_FALSE(texture->haveBackingTexture()); + EXPECT_FALSE(texture->have_backing_texture()); - texture->setRequestPriority(100); + texture->set_request_priority(100); prioritizeTexturesAndBackings(resourceManager.get()); EXPECT_TRUE(validateTexture(texture, false)); - EXPECT_TRUE(texture->canAcquireBackingTexture()); - EXPECT_TRUE(texture->haveBackingTexture()); + EXPECT_TRUE(texture->can_acquire_backing_texture()); + EXPECT_TRUE(texture->have_backing_texture()); { DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy); @@ -381,8 +381,8 @@ TEST_F(PrioritizedResourceTest, resourceManagerDestroyedFirst) } resourceManager.reset(); - EXPECT_FALSE(texture->canAcquireBackingTexture()); - EXPECT_FALSE(texture->haveBackingTexture()); + EXPECT_FALSE(texture->can_acquire_backing_texture()); + EXPECT_FALSE(texture->have_backing_texture()); } TEST_F(PrioritizedResourceTest, textureMovedToNewManager) @@ -392,16 +392,16 @@ TEST_F(PrioritizedResourceTest, textureMovedToNewManager) scoped_ptr<PrioritizedResource> texture = resourceManagerOne->createTexture(m_textureSize, m_textureFormat); // Texture is initially invalid, but it will become available. - EXPECT_FALSE(texture->haveBackingTexture()); + EXPECT_FALSE(texture->have_backing_texture()); - texture->setRequestPriority(100); + texture->set_request_priority(100); prioritizeTexturesAndBackings(resourceManagerOne.get()); EXPECT_TRUE(validateTexture(texture, false)); - EXPECT_TRUE(texture->canAcquireBackingTexture()); - EXPECT_TRUE(texture->haveBackingTexture()); + EXPECT_TRUE(texture->can_acquire_backing_texture()); + EXPECT_TRUE(texture->have_backing_texture()); - texture->setTextureManager(0); + texture->SetTextureManager(0); { DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy); @@ -409,16 +409,16 @@ TEST_F(PrioritizedResourceTest, textureMovedToNewManager) } resourceManagerOne.reset(); - EXPECT_FALSE(texture->canAcquireBackingTexture()); - EXPECT_FALSE(texture->haveBackingTexture()); + EXPECT_FALSE(texture->can_acquire_backing_texture()); + EXPECT_FALSE(texture->have_backing_texture()); - texture->setTextureManager(resourceManagerTwo.get()); + texture->SetTextureManager(resourceManagerTwo.get()); prioritizeTexturesAndBackings(resourceManagerTwo.get()); EXPECT_TRUE(validateTexture(texture, false)); - EXPECT_TRUE(texture->canAcquireBackingTexture()); - EXPECT_TRUE(texture->haveBackingTexture()); + EXPECT_TRUE(texture->can_acquire_backing_texture()); + EXPECT_TRUE(texture->have_backing_texture()); DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy); resourceManagerTwo->clearAllMemory(resourceProvider()); @@ -431,8 +431,8 @@ TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableOutsideRootSu // Half of the memory is taken by surfaces (with high priority place-holder) scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager->createTexture(m_textureSize, m_textureFormat); - renderSurfacePlaceHolder->setToSelfManagedMemoryPlaceholder(texturesMemorySize(4)); - renderSurfacePlaceHolder->setRequestPriority(PriorityCalculator::RenderSurfacePriority()); + renderSurfacePlaceHolder->SetToSelfManagedMemoryPlaceholder(texturesMemorySize(4)); + renderSurfacePlaceHolder->set_request_priority(PriorityCalculator::RenderSurfacePriority()); // Create textures to fill our memory limit. scoped_ptr<PrioritizedResource> textures[maxTextures]; @@ -442,7 +442,7 @@ TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableOutsideRootSu // Set decreasing non-visible priorities outside root surface. for (size_t i = 0; i < maxTextures; ++i) - textures[i]->setRequestPriority(100 + i); + textures[i]->set_request_priority(100 + i); // Only lower half should be available. prioritizeTexturesAndBackings(resourceManager.get()); @@ -453,7 +453,7 @@ TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableOutsideRootSu // Set increasing non-visible priorities outside root surface. for (size_t i = 0; i < maxTextures; ++i) - textures[i]->setRequestPriority(100 - i); + textures[i]->set_request_priority(100 - i); // Only upper half should be available. prioritizeTexturesAndBackings(resourceManager.get()); @@ -477,8 +477,8 @@ TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableForRequestLat // Half of the memory is taken by surfaces (with high priority place-holder) scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager->createTexture(m_textureSize, m_textureFormat); - renderSurfacePlaceHolder->setToSelfManagedMemoryPlaceholder(texturesMemorySize(4)); - renderSurfacePlaceHolder->setRequestPriority(PriorityCalculator::RenderSurfacePriority()); + renderSurfacePlaceHolder->SetToSelfManagedMemoryPlaceholder(texturesMemorySize(4)); + renderSurfacePlaceHolder->set_request_priority(PriorityCalculator::RenderSurfacePriority()); // Create textures to fill our memory limit. scoped_ptr<PrioritizedResource> textures[maxTextures]; @@ -488,7 +488,7 @@ TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableForRequestLat // Set equal priorities. for (size_t i = 0; i < maxTextures; ++i) - textures[i]->setRequestPriority(100); + textures[i]->set_request_priority(100); // The first four to be requested late will be available. prioritizeTexturesAndBackings(resourceManager.get()); @@ -514,8 +514,8 @@ TEST_F(PrioritizedResourceTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvai // Half of the memory is taken by surfaces (with high priority place-holder) scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager->createTexture(m_textureSize, m_textureFormat); - renderSurfacePlaceHolder->setToSelfManagedMemoryPlaceholder(texturesMemorySize(4)); - renderSurfacePlaceHolder->setRequestPriority(PriorityCalculator::RenderSurfacePriority()); + renderSurfacePlaceHolder->SetToSelfManagedMemoryPlaceholder(texturesMemorySize(4)); + renderSurfacePlaceHolder->set_request_priority(PriorityCalculator::RenderSurfacePriority()); // Create textures to fill our memory limit. scoped_ptr<PrioritizedResource> textures[maxTextures]; @@ -525,9 +525,9 @@ TEST_F(PrioritizedResourceTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvai // Set 6 visible textures in the root surface, and 2 in a child surface. for (size_t i = 0; i < 6; ++i) - textures[i]->setRequestPriority(PriorityCalculator::VisiblePriority(true)); + textures[i]->set_request_priority(PriorityCalculator::VisiblePriority(true)); for (size_t i = 6; i < 8; ++i) - textures[i]->setRequestPriority(PriorityCalculator::VisiblePriority(false)); + textures[i]->set_request_priority(PriorityCalculator::VisiblePriority(false)); prioritizeTexturesAndBackings(resourceManager.get()); @@ -560,7 +560,7 @@ TEST_F(PrioritizedResourceTest, requestLateBackingsSorting) // Set equal priorities, and allocate backings for all textures. for (size_t i = 0; i < maxTextures; ++i) - textures[i]->setRequestPriority(100); + textures[i]->set_request_priority(100); prioritizeTexturesAndBackings(resourceManager.get()); for (unsigned i = 0; i < maxTextures; ++i) EXPECT_TRUE(validateTexture(textures[i], false)); @@ -572,7 +572,7 @@ TEST_F(PrioritizedResourceTest, requestLateBackingsSorting) // Push half of them back over the limit. for (size_t i = 0; i < maxTextures; i += 2) - EXPECT_TRUE(textures[i]->requestLate()); + EXPECT_TRUE(textures[i]->RequestLate()); // Push the priorities to the backings array and sort the backings array resourceManagerUpdateBackingsPriorities(resourceManager.get()); @@ -583,7 +583,7 @@ TEST_F(PrioritizedResourceTest, requestLateBackingsSorting) // Make sure that we have backings for all of the textures. for (size_t i = 0; i < maxTextures; ++i) - EXPECT_TRUE(textures[i]->haveBackingTexture()); + EXPECT_TRUE(textures[i]->have_backing_texture()); // Make sure that only the requestLate textures are above the priority cutoff for (size_t i = 0; i < maxTextures; i += 2) @@ -610,7 +610,7 @@ TEST_F(PrioritizedResourceTest, clearUploadsToEvictedResources) // Set equal priorities, and allocate backings for all textures. for (size_t i = 0; i < maxTextures; ++i) - textures[i]->setRequestPriority(100); + textures[i]->set_request_priority(100); prioritizeTexturesAndBackings(resourceManager.get()); for (unsigned i = 0; i < maxTextures; ++i) EXPECT_TRUE(validateTexture(textures[i], false)); @@ -625,7 +625,7 @@ TEST_F(PrioritizedResourceTest, clearUploadsToEvictedResources) // Make sure that we have backings for all of the textures. for (size_t i = 0; i < maxTextures; ++i) - EXPECT_TRUE(textures[i]->haveBackingTexture()); + EXPECT_TRUE(textures[i]->have_backing_texture()); queue.clearUploadsToEvictedResources(); EXPECT_EQ(4, queue.fullUploadSize()); @@ -650,11 +650,11 @@ TEST_F(PrioritizedResourceTest, usageStatistics) for (size_t i = 0; i < maxTextures; ++i) textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); - textures[0]->setRequestPriority(PriorityCalculator::AllowVisibleOnlyCutoff() - 1); - textures[1]->setRequestPriority(PriorityCalculator::AllowVisibleOnlyCutoff()); - textures[2]->setRequestPriority(PriorityCalculator::AllowVisibleAndNearbyCutoff() - 1); - textures[3]->setRequestPriority(PriorityCalculator::AllowVisibleAndNearbyCutoff()); - textures[4]->setRequestPriority(PriorityCalculator::AllowVisibleAndNearbyCutoff() + 1); + textures[0]->set_request_priority(PriorityCalculator::AllowVisibleOnlyCutoff() - 1); + textures[1]->set_request_priority(PriorityCalculator::AllowVisibleOnlyCutoff()); + textures[2]->set_request_priority(PriorityCalculator::AllowVisibleAndNearbyCutoff() - 1); + textures[3]->set_request_priority(PriorityCalculator::AllowVisibleAndNearbyCutoff()); + textures[4]->set_request_priority(PriorityCalculator::AllowVisibleAndNearbyCutoff() + 1); // Set max limit to 2 textures. resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(2)); @@ -675,11 +675,11 @@ TEST_F(PrioritizedResourceTest, usageStatistics) } // Re-prioritize the textures, but do not push the values to backings. - textures[0]->setRequestPriority(PriorityCalculator::AllowVisibleOnlyCutoff() - 1); - textures[1]->setRequestPriority(PriorityCalculator::AllowVisibleOnlyCutoff() - 1); - textures[2]->setRequestPriority(PriorityCalculator::AllowVisibleOnlyCutoff() - 1); - textures[3]->setRequestPriority(PriorityCalculator::AllowVisibleAndNearbyCutoff() - 1); - textures[4]->setRequestPriority(PriorityCalculator::AllowVisibleAndNearbyCutoff()); + textures[0]->set_request_priority(PriorityCalculator::AllowVisibleOnlyCutoff() - 1); + textures[1]->set_request_priority(PriorityCalculator::AllowVisibleOnlyCutoff() - 1); + textures[2]->set_request_priority(PriorityCalculator::AllowVisibleOnlyCutoff() - 1); + textures[3]->set_request_priority(PriorityCalculator::AllowVisibleAndNearbyCutoff() - 1); + textures[4]->set_request_priority(PriorityCalculator::AllowVisibleAndNearbyCutoff()); resourceManager->prioritizeTextures(); // Verify that we still see the old values. diff --git a/cc/resources/resource_update_controller.cc b/cc/resources/resource_update_controller.cc index 112ebe4..b568f5c 100644 --- a/cc/resources/resource_update_controller.cc +++ b/cc/resources/resource_update_controller.cc @@ -117,17 +117,17 @@ void ResourceUpdateController::UpdateTexture(ResourceUpdate update) { gfx::Rect source_rect = update.source_rect; gfx::Vector2d dest_offset = update.dest_offset; - texture->acquireBackingTexture(resource_provider_); - DCHECK(texture->haveBackingTexture()); + texture->AcquireBackingTexture(resource_provider_); + DCHECK(texture->have_backing_texture()); - DCHECK(resource_provider_->GetResourceType(texture->resourceId()) == + DCHECK(resource_provider_->GetResourceType(texture->ResourceId()) == ResourceProvider::GLTexture); cc::ContextProvider* offscreen_contexts = resource_provider_->offscreen_context_provider(); ResourceProvider::ScopedWriteLockGL lock( - resource_provider_, texture->resourceId()); + resource_provider_, texture->ResourceId()); // Flush the compositor context to ensure that textures there are available // in the shared context. Do this after locking/creating the compositor @@ -172,7 +172,7 @@ void ResourceUpdateController::UpdateTexture(ResourceUpdate update) { if (update.bitmap) { update.bitmap->lockPixels(); - update.texture->setPixels( + update.texture->SetPixels( resource_provider_, static_cast<const uint8_t*>(update.bitmap->getPixels()), update.content_rect, diff --git a/cc/resources/resource_update_controller_unittest.cc b/cc/resources/resource_update_controller_unittest.cc index 752abd2..708f3d9 100644 --- a/cc/resources/resource_update_controller_unittest.cc +++ b/cc/resources/resource_update_controller_unittest.cc @@ -126,9 +126,9 @@ protected: m_bitmap.allocPixels(); for (int i = 0; i < 4; i++) { - m_textures[i] = PrioritizedResource::create( + m_textures[i] = PrioritizedResource::Create( m_resourceManager.get(), gfx::Size(300, 150), GL_RGBA); - m_textures[i]->setRequestPriority( + m_textures[i]->set_request_priority( PriorityCalculator::VisiblePriority(true)); } m_resourceManager->prioritizeTextures(); diff --git a/cc/resources/resource_update_queue.cc b/cc/resources/resource_update_queue.cc index d301638..e94f218 100644 --- a/cc/resources/resource_update_queue.cc +++ b/cc/resources/resource_update_queue.cc @@ -44,7 +44,7 @@ void ResourceUpdateQueue::clearUploadsToEvictedResources(std::deque<ResourceUpda while (temp.size()) { ResourceUpdate upload = temp.front(); temp.pop_front(); - if (!upload.texture->backingResourceWasEvicted()) + if (!upload.texture->BackingResourceWasEvicted()) entryQueue.push_back(upload); } } diff --git a/cc/resources/skpicture_content_layer_updater.cc b/cc/resources/skpicture_content_layer_updater.cc index a44dcc3..1af05f9 100644 --- a/cc/resources/skpicture_content_layer_updater.cc +++ b/cc/resources/skpicture_content_layer_updater.cc @@ -42,7 +42,7 @@ SkPictureContentLayerUpdater::Create(scoped_ptr<LayerPainter> painter) { scoped_ptr<LayerUpdater::Resource> SkPictureContentLayerUpdater::CreateResource( PrioritizedResourceManager* manager) { return scoped_ptr<LayerUpdater::Resource>( - new Resource(this, PrioritizedResource::create(manager))); + new Resource(this, PrioritizedResource::Create(manager))); } void SkPictureContentLayerUpdater::PrepareToUpdate( diff --git a/cc/test/fake_content_layer.cc b/cc/test/fake_content_layer.cc index 69cdb1f..384521c 100644 --- a/cc/test/fake_content_layer.cc +++ b/cc/test/fake_content_layer.cc @@ -33,7 +33,7 @@ void FakeContentLayer::Update(ResourceUpdateQueue* queue, bool FakeContentLayer::HaveBackingAt(int i, int j) { const PrioritizedResource* resource = ResourceAtForTesting(i, j); - return resource && resource->haveBackingTexture(); + return resource && resource->have_backing_texture(); } } // namespace cc diff --git a/cc/test/tiled_layer_test_common.cc b/cc/test/tiled_layer_test_common.cc index e1043d3..67ca38c 100644 --- a/cc/test/tiled_layer_test_common.cc +++ b/cc/test/tiled_layer_test_common.cc @@ -70,7 +70,7 @@ void FakeLayerUpdater::setRectToInvalidate(const gfx::Rect& rect, FakeTiledLayer scoped_ptr<LayerUpdater::Resource> FakeLayerUpdater::CreateResource(PrioritizedResourceManager* manager) { - return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedResource::create(manager))); + return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedResource::Create(manager))); } FakeTiledLayerImpl::FakeTiledLayerImpl(LayerTreeImpl* treeImpl, int id) diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index afb38cb..cb195db 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -716,11 +716,11 @@ void LayerTreeHost::TriggerPrepaint() { void LayerTreeHost::SetPrioritiesForSurfaces(size_t surface_memory_bytes) { // Surfaces have a place holder for their memory since they are managed // independantly but should still be tracked and reduce other memory usage. - surface_memory_placeholder_->setTextureManager( + surface_memory_placeholder_->SetTextureManager( contents_texture_manager_.get()); - surface_memory_placeholder_->setRequestPriority( + surface_memory_placeholder_->set_request_priority( PriorityCalculator::RenderSurfacePriority()); - surface_memory_placeholder_->setToSelfManagedMemoryPlaceholder( + surface_memory_placeholder_->SetToSelfManagedMemoryPlaceholder( surface_memory_bytes); } diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 258636d..7b4230a 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -1495,7 +1495,7 @@ public: virtual void PushPropertiesTo(LayerImpl*) OVERRIDE; virtual void SetTexturePriorities(const PriorityCalculator&) OVERRIDE; - bool haveBackingTexture() const { return m_texture.get() ? m_texture->haveBackingTexture() : false; } + bool haveBackingTexture() const { return m_texture.get() ? m_texture->have_backing_texture() : false; } private: EvictionTestLayer() : Layer() { } @@ -1505,8 +1505,8 @@ private: { if (m_texture.get()) return; - m_texture = PrioritizedResource::create(layer_tree_host()->contents_texture_manager()); - m_texture->setDimensions(gfx::Size(10, 10), GL_RGBA); + m_texture = PrioritizedResource::Create(layer_tree_host()->contents_texture_manager()); + m_texture->SetDimensions(gfx::Size(10, 10), GL_RGBA); m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); } @@ -1544,7 +1544,7 @@ void EvictionTestLayer::SetTexturePriorities(const PriorityCalculator&) createTextureIfNeeded(); if (!m_texture.get()) return; - m_texture->setRequestPriority(PriorityCalculator::UIPriority(true)); + m_texture->set_request_priority(PriorityCalculator::UIPriority(true)); } void EvictionTestLayer::Update(ResourceUpdateQueue* queue, const OcclusionTracker*, RenderingStats*) @@ -1569,7 +1569,7 @@ void EvictionTestLayer::PushPropertiesTo(LayerImpl* layerImpl) Layer::PushPropertiesTo(layerImpl); EvictionTestLayerImpl* testLayerImpl = static_cast<EvictionTestLayerImpl*>(layerImpl); - testLayerImpl->setHasTexture(m_texture->haveBackingTexture()); + testLayerImpl->setHasTexture(m_texture->have_backing_texture()); } class LayerTreeHostTestEvictTextures : public LayerTreeHostTest { |