| 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/layers/image_layer.h" | 5 #include "cc/layers/image_layer.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "cc/resources/image_layer_updater.h" | 8 #include "cc/resources/image_layer_updater.h" |
| 9 #include "cc/resources/layer_updater.h" | 9 #include "cc/resources/layer_updater.h" |
| 10 #include "cc/resources/prioritized_resource.h" | 10 #include "cc/resources/prioritized_resource.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 void ImageLayer::SetTexturePriorities(const PriorityCalculator& priority_calc) { | 36 void ImageLayer::SetTexturePriorities(const PriorityCalculator& priority_calc) { |
| 37 // Update the tile data before creating all the layer's tiles. | 37 // Update the tile data before creating all the layer's tiles. |
| 38 UpdateTileSizeAndTilingOption(); | 38 UpdateTileSizeAndTilingOption(); |
| 39 | 39 |
| 40 TiledLayer::SetTexturePriorities(priority_calc); | 40 TiledLayer::SetTexturePriorities(priority_calc); |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool ImageLayer::Update(ResourceUpdateQueue* queue, | 43 bool ImageLayer::Update(ResourceUpdateQueue* queue, |
| 44 const OcclusionTracker* occlusion) { | 44 const OcclusionTracker* occlusion) { |
| 45 CreateUpdaterIfNeeded(); | 45 CreateUpdaterIfNeeded(); |
| 46 if (needs_display_) { | 46 if (!updater_->UsingBitmap(bitmap_)) { |
| 47 updater_->set_bitmap(bitmap_); | 47 updater_->SetBitmap(bitmap_); |
| 48 UpdateTileSizeAndTilingOption(); | 48 UpdateTileSizeAndTilingOption(); |
| 49 InvalidateContentRect(gfx::Rect(content_bounds())); | 49 InvalidateContentRect(gfx::Rect(content_bounds())); |
| 50 needs_display_ = false; | |
| 51 } | 50 } |
| 52 return TiledLayer::Update(queue, occlusion); | 51 return TiledLayer::Update(queue, occlusion); |
| 53 } | 52 } |
| 54 | 53 |
| 55 void ImageLayer::CreateUpdaterIfNeeded() { | 54 void ImageLayer::CreateUpdaterIfNeeded() { |
| 56 if (updater_.get()) | 55 if (updater_.get()) |
| 57 return; | 56 return; |
| 58 | 57 |
| 59 updater_ = ImageLayerUpdater::Create(); | 58 updater_ = ImageLayerUpdater::Create(); |
| 60 GLenum texture_format = | 59 GLenum texture_format = |
| (...skipping 27 matching lines...) Expand all Loading... |
| 88 return static_cast<float>(bitmap_.width()) / bounds().width(); | 87 return static_cast<float>(bitmap_.width()) / bounds().width(); |
| 89 } | 88 } |
| 90 | 89 |
| 91 float ImageLayer::ImageContentsScaleY() const { | 90 float ImageLayer::ImageContentsScaleY() const { |
| 92 if (bounds().IsEmpty() || bitmap_.height() == 0) | 91 if (bounds().IsEmpty() || bitmap_.height() == 0) |
| 93 return 1; | 92 return 1; |
| 94 return static_cast<float>(bitmap_.height()) / bounds().height(); | 93 return static_cast<float>(bitmap_.height()) / bounds().height(); |
| 95 } | 94 } |
| 96 | 95 |
| 97 } // namespace cc | 96 } // namespace cc |
| OLD | NEW |