OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |