| 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" |
| 11 #include "cc/resources/resource_update_queue.h" | 11 #include "cc/resources/resource_update_queue.h" |
| 12 #include "cc/trees/layer_tree_host.h" | 12 #include "cc/trees/layer_tree_host.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 scoped_refptr<ImageLayer> ImageLayer::Create() { | 16 scoped_refptr<ImageLayer> ImageLayer::Create(const LayerSettings& settings) { |
| 17 return make_scoped_refptr(new ImageLayer()); | 17 return make_scoped_refptr(new ImageLayer(settings)); |
| 18 } | 18 } |
| 19 | 19 |
| 20 ImageLayer::ImageLayer() : TiledLayer() {} | 20 ImageLayer::ImageLayer(const LayerSettings& settings) : TiledLayer(settings) { |
| 21 } |
| 21 | 22 |
| 22 ImageLayer::~ImageLayer() {} | 23 ImageLayer::~ImageLayer() {} |
| 23 | 24 |
| 24 void ImageLayer::SetBitmap(const SkBitmap& bitmap) { | 25 void ImageLayer::SetBitmap(const SkBitmap& bitmap) { |
| 25 // SetBitmap() currently gets called whenever there is any | 26 // SetBitmap() currently gets called whenever there is any |
| 26 // style change that affects the layer even if that change doesn't | 27 // style change that affects the layer even if that change doesn't |
| 27 // affect the actual contents of the image (e.g. a CSS animation). | 28 // affect the actual contents of the image (e.g. a CSS animation). |
| 28 // With this check in place we avoid unecessary texture uploads. | 29 // With this check in place we avoid unecessary texture uploads. |
| 29 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef()) | 30 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef()) |
| 30 return; | 31 return; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 return static_cast<float>(bitmap_.width()) / bounds().width(); | 91 return static_cast<float>(bitmap_.width()) / bounds().width(); |
| 91 } | 92 } |
| 92 | 93 |
| 93 float ImageLayer::ImageContentsScaleY() const { | 94 float ImageLayer::ImageContentsScaleY() const { |
| 94 if (bounds().IsEmpty() || bitmap_.height() == 0) | 95 if (bounds().IsEmpty() || bitmap_.height() == 0) |
| 95 return 1; | 96 return 1; |
| 96 return static_cast<float>(bitmap_.height()) / bounds().height(); | 97 return static_cast<float>(bitmap_.height()) / bounds().height(); |
| 97 } | 98 } |
| 98 | 99 |
| 99 } // namespace cc | 100 } // namespace cc |
| OLD | NEW |