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::calculateContentsScale( |
| 78 float ideal_contents_scale, |
| 79 float* contentsScaleX, |
| 80 float* contentsScaleY, |
| 81 gfx::Size* contentBounds) |
78 { | 82 { |
79 return gfx::Size(m_bitmap.width(), m_bitmap.height()); | 83 *contentsScaleX = imageContentsScaleX(); |
| 84 *contentsScaleY = imageContentsScaleY(); |
| 85 *contentBounds = gfx::Size(m_bitmap.width(), m_bitmap.height()); |
80 } | 86 } |
81 | 87 |
82 bool ImageLayer::drawsContent() const | 88 bool ImageLayer::drawsContent() const |
83 { | 89 { |
84 return !m_bitmap.isNull() && TiledLayer::drawsContent(); | 90 return !m_bitmap.isNull() && TiledLayer::drawsContent(); |
85 } | 91 } |
86 | 92 |
87 float ImageLayer::contentsScaleX() const | 93 float ImageLayer::imageContentsScaleX() const |
88 { | 94 { |
89 if (bounds().IsEmpty() || contentBounds().IsEmpty()) | 95 if (bounds().IsEmpty() || m_bitmap.width() == 0) |
90 return 1; | 96 return 1; |
91 return static_cast<float>(m_bitmap.width()) / bounds().width(); | 97 return static_cast<float>(m_bitmap.width()) / bounds().width(); |
92 } | 98 } |
93 | 99 |
94 float ImageLayer::contentsScaleY() const | 100 float ImageLayer::imageContentsScaleY() const |
95 { | 101 { |
96 if (bounds().IsEmpty() || contentBounds().IsEmpty()) | 102 if (bounds().IsEmpty() || m_bitmap.height() == 0) |
97 return 1; | 103 return 1; |
98 return static_cast<float>(m_bitmap.height()) / bounds().height(); | 104 return static_cast<float>(m_bitmap.height()) / bounds().height(); |
99 } | 105 } |
100 | 106 |
101 } // namespace cc | 107 } // namespace cc |
OLD | NEW |