OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "cc/image_layer.h" | 5 #include "cc/image_layer.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "cc/image_layer_updater.h" | 8 #include "cc/image_layer_updater.h" |
9 #include "cc/layer_updater.h" | 9 #include "cc/layer_updater.h" |
10 #include "cc/layer_tree_host.h" | 10 #include "cc/layer_tree_host.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 m_updater = ImageLayerUpdater::create(); | 67 m_updater = ImageLayerUpdater::create(); |
68 GLenum textureFormat = layerTreeHost()->rendererCapabilities().bestTextureFo
rmat; | 68 GLenum textureFormat = layerTreeHost()->rendererCapabilities().bestTextureFo
rmat; |
69 setTextureFormat(textureFormat); | 69 setTextureFormat(textureFormat); |
70 } | 70 } |
71 | 71 |
72 LayerUpdater* ImageLayer::updater() const | 72 LayerUpdater* ImageLayer::updater() const |
73 { | 73 { |
74 return m_updater.get(); | 74 return m_updater.get(); |
75 } | 75 } |
76 | 76 |
77 gfx::Size ImageLayer::contentBounds() const | 77 void ImageLayer::updateContentsScale(float ideal_contents_scale) |
78 { | 78 { |
79 return gfx::Size(m_bitmap.width(), m_bitmap.height()); | 79 m_drawProperties.contents_scale_x = imageContentsScaleX(); |
| 80 m_drawProperties.contents_scale_y = imageContentsScaleY(); |
| 81 m_drawProperties.content_bounds = gfx::Size(m_bitmap.width(), m_bitmap.heigh
t()); |
80 } | 82 } |
81 | 83 |
82 bool ImageLayer::drawsContent() const | 84 bool ImageLayer::drawsContent() const |
83 { | 85 { |
84 return !m_bitmap.isNull() && TiledLayer::drawsContent(); | 86 return !m_bitmap.isNull() && TiledLayer::drawsContent(); |
85 } | 87 } |
86 | 88 |
87 float ImageLayer::contentsScaleX() const | 89 float ImageLayer::imageContentsScaleX() const |
88 { | 90 { |
89 if (bounds().IsEmpty() || contentBounds().IsEmpty()) | 91 if (bounds().IsEmpty() || m_bitmap.width() == 0) |
90 return 1; | 92 return 1; |
91 return static_cast<float>(m_bitmap.width()) / bounds().width(); | 93 return static_cast<float>(m_bitmap.width()) / bounds().width(); |
92 } | 94 } |
93 | 95 |
94 float ImageLayer::contentsScaleY() const | 96 float ImageLayer::imageContentsScaleY() const |
95 { | 97 { |
96 if (bounds().IsEmpty() || contentBounds().IsEmpty()) | 98 if (bounds().IsEmpty() || m_bitmap.height() == 0) |
97 return 1; | 99 return 1; |
98 return static_cast<float>(m_bitmap.height()) / bounds().height(); | 100 return static_cast<float>(m_bitmap.height()) / bounds().height(); |
99 } | 101 } |
100 | 102 |
101 } // namespace cc | 103 } // namespace cc |
OLD | NEW |