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

Side by Side Diff: cc/nine_patch_layer.cc

Issue 11377017: cc: Fix nine patch layer resource management bugs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
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 unified diff | Download patch
« no previous file with comments | « no previous file | cc/nine_patch_layer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "cc/nine_patch_layer.h" 7 #include "cc/nine_patch_layer.h"
8 8
9 #include "cc/layer_tree_host.h" 9 #include "cc/layer_tree_host.h"
10 #include "cc/nine_patch_layer_impl.h" 10 #include "cc/nine_patch_layer_impl.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 m_bitmap = bitmap; 56 m_bitmap = bitmap;
57 m_imageAperture = aperture; 57 m_imageAperture = aperture;
58 m_bitmapDirty = true; 58 m_bitmapDirty = true;
59 setNeedsDisplay(); 59 setNeedsDisplay();
60 } 60 }
61 61
62 void NinePatchLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) 62 void NinePatchLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats)
63 { 63 {
64 createUpdaterIfNeeded(); 64 createUpdaterIfNeeded();
65 65
66 if (m_resource && (m_bitmapDirty || m_resource->texture()->backingResourceWa sEvicted())) { 66 if (m_resource && (m_bitmapDirty || m_resource->texture()->resourceId() == 0 )) {
67 gfx::Rect contentRect(gfx::Point(), gfx::Size(m_bitmap.width(), m_bitmap .height())); 67 gfx::Rect contentRect(gfx::Point(), gfx::Size(m_bitmap.width(), m_bitmap .height()));
68 ResourceUpdate upload = ResourceUpdate::Create(m_resource->texture(), &m _bitmap, contentRect, contentRect, gfx::Vector2d()); 68 ResourceUpdate upload = ResourceUpdate::Create(m_resource->texture(), &m _bitmap, contentRect, contentRect, gfx::Vector2d());
69 queue.appendFullUpload(upload); 69 queue.appendFullUpload(upload);
70 m_bitmapDirty = false; 70 m_bitmapDirty = false;
71 } 71 }
72 } 72 }
73 73
74 void NinePatchLayer::createUpdaterIfNeeded() 74 void NinePatchLayer::createUpdaterIfNeeded()
75 { 75 {
76 if (m_updater) 76 if (m_updater)
77 return; 77 return;
78 78
79 m_updater = ImageLayerUpdater::create(); 79 m_updater = ImageLayerUpdater::create();
80 } 80 }
81 81
82 bool NinePatchLayer::drawsContent() const 82 bool NinePatchLayer::drawsContent() const
83 { 83 {
84 bool draws = !m_bitmap.isNull() && Layer::drawsContent() && m_bitmap.width() && m_bitmap.height(); 84 bool draws = !m_bitmap.isNull() && Layer::drawsContent() && m_bitmap.width() && m_bitmap.height();
85 return draws; 85 return draws;
86 } 86 }
87 87
88 void NinePatchLayer::pushPropertiesTo(LayerImpl* layer) 88 void NinePatchLayer::pushPropertiesTo(LayerImpl* layer)
89 { 89 {
90 Layer::pushPropertiesTo(layer); 90 Layer::pushPropertiesTo(layer);
91 NinePatchLayerImpl* layerImpl = static_cast<NinePatchLayerImpl*>(layer); 91 NinePatchLayerImpl* layerImpl = static_cast<NinePatchLayerImpl*>(layer);
92 92
93 DCHECK(!m_bitmap.isNull()); 93 if (m_resource) {
94 DCHECK(m_resource); 94 DCHECK(!m_bitmap.isNull());
95 layerImpl->setResourceId(m_resource->texture()->resourceId()); 95 layerImpl->setResourceId(m_resource->texture()->resourceId());
96 layerImpl->setLayout(gfx::Size(m_bitmap.width(), m_bitmap.height()), m_image Aperture); 96 layerImpl->setLayout(gfx::Size(m_bitmap.width(), m_bitmap.height()), m_i mageAperture);
97 }
97 } 98 }
98 99
99 } 100 }
OLDNEW
« no previous file with comments | « no previous file | cc/nine_patch_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698