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

Unified Diff: cc/nine_patch_layer.cc

Issue 11420021: Handle NinePatchLayer Resource Rebuilding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/nine_patch_layer.h ('k') | cc/nine_patch_layer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/nine_patch_layer.cc
diff --git a/cc/nine_patch_layer.cc b/cc/nine_patch_layer.cc
index 5fce67513cdfe616b1ef8d99b9ab63a924834ec6..b4001b2d68d106d566aedc0dac8d0c31accfe7cf 100644
--- a/cc/nine_patch_layer.cc
+++ b/cc/nine_patch_layer.cc
@@ -32,14 +32,13 @@ scoped_ptr<LayerImpl> NinePatchLayer::createLayerImpl()
void NinePatchLayer::setTexturePriorities(const PriorityCalculator& priorityCalc)
{
- if (m_needsDisplay && m_bitmapDirty && drawsContent()) {
- DCHECK(!m_bitmap.isNull());
- createUpdaterIfNeeded();
- m_updater->setBitmap(m_bitmap);
- m_needsDisplay = false;
-
- if (!m_resource)
- m_resource = m_updater->createResource(layerTreeHost()->contentsTextureManager());
+ if (m_resource && !m_resource->texture()->resourceManager()) {
+ // Release the resource here, as it is no longer tied to a resource manager.
+ m_resource.reset();
+ if (!m_bitmap.isNull())
+ createResource();
+ } else if (m_needsDisplay && m_bitmapDirty && drawsContent()) {
+ createResource();
}
if (m_resource) {
@@ -77,6 +76,17 @@ void NinePatchLayer::createUpdaterIfNeeded()
m_updater = ImageLayerUpdater::create();
}
+void NinePatchLayer::createResource()
+{
+ DCHECK(!m_bitmap.isNull());
+ createUpdaterIfNeeded();
+ m_updater->setBitmap(m_bitmap);
+ m_needsDisplay = false;
+
+ if (!m_resource)
+ m_resource = m_updater->createResource(layerTreeHost()->contentsTextureManager());
+}
+
bool NinePatchLayer::drawsContent() const
{
bool draws = !m_bitmap.isNull() && Layer::drawsContent() && m_bitmap.width() && m_bitmap.height();
« no previous file with comments | « cc/nine_patch_layer.h ('k') | cc/nine_patch_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698