Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 void ImageLayer::SetBitmap(const SkBitmap& bitmap) { | 24 void ImageLayer::SetBitmap(const SkBitmap& bitmap) { |
| 25 // SetBitmap() currently gets called whenever there is any | 25 // SetBitmap() currently gets called whenever there is any |
| 26 // style change that affects the layer even if that change doesn't | 26 // 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). | 27 // affect the actual contents of the image (e.g. a CSS animation). |
| 28 // With this check in place we avoid unecessary texture uploads. | 28 // With this check in place we avoid unecessary texture uploads. |
| 29 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef()) | 29 if (bitmap.pixelRef() && bitmap.pixelRef() == bitmap_.pixelRef()) |
| 30 return; | 30 return; |
| 31 | 31 |
| 32 bitmap_ = bitmap; | 32 bitmap_ = bitmap; |
| 33 UpdateDrawsContent(true); | |
| 33 SetNeedsDisplay(); | 34 SetNeedsDisplay(); |
| 34 } | 35 } |
| 35 | 36 |
| 37 void ImageLayer::UpdateDrawsContent(bool drawsContent) { | |
|
danakj
2014/07/14 14:56:31
draws_content thoughout
awoloszyn
2014/07/14 19:38:32
Done.
| |
| 38 TiledLayer::UpdateDrawsContent(drawsContent && !bitmap_.isNull()); | |
|
danakj
2014/07/14 14:56:31
so I think what you're trying to do here, you want
awoloszyn
2014/07/14 15:25:09
So how I had set UpateDrawsContent up, currently,
| |
| 39 } | |
| 40 | |
| 36 void ImageLayer::SetTexturePriorities(const PriorityCalculator& priority_calc) { | 41 void ImageLayer::SetTexturePriorities(const PriorityCalculator& priority_calc) { |
| 37 // Update the tile data before creating all the layer's tiles. | 42 // Update the tile data before creating all the layer's tiles. |
| 38 UpdateTileSizeAndTilingOption(); | 43 UpdateTileSizeAndTilingOption(); |
| 39 | 44 |
| 40 TiledLayer::SetTexturePriorities(priority_calc); | 45 TiledLayer::SetTexturePriorities(priority_calc); |
| 41 } | 46 } |
| 42 | 47 |
| 43 bool ImageLayer::Update(ResourceUpdateQueue* queue, | 48 bool ImageLayer::Update(ResourceUpdateQueue* queue, |
| 44 const OcclusionTracker<Layer>* occlusion) { | 49 const OcclusionTracker<Layer>* occlusion) { |
| 45 CreateUpdaterIfNeeded(); | 50 CreateUpdaterIfNeeded(); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 70 float maximum_animation_contents_scale, | 75 float maximum_animation_contents_scale, |
| 71 bool animating_transform_to_screen, | 76 bool animating_transform_to_screen, |
| 72 float* contents_scale_x, | 77 float* contents_scale_x, |
| 73 float* contents_scale_y, | 78 float* contents_scale_y, |
| 74 gfx::Size* content_bounds) { | 79 gfx::Size* content_bounds) { |
| 75 *contents_scale_x = ImageContentsScaleX(); | 80 *contents_scale_x = ImageContentsScaleX(); |
| 76 *contents_scale_y = ImageContentsScaleY(); | 81 *contents_scale_y = ImageContentsScaleY(); |
| 77 *content_bounds = gfx::Size(bitmap_.width(), bitmap_.height()); | 82 *content_bounds = gfx::Size(bitmap_.width(), bitmap_.height()); |
| 78 } | 83 } |
| 79 | 84 |
| 80 bool ImageLayer::DrawsContent() const { | |
| 81 return !bitmap_.isNull() && TiledLayer::DrawsContent(); | |
| 82 } | |
| 83 | |
| 84 void ImageLayer::OnOutputSurfaceCreated() { | 85 void ImageLayer::OnOutputSurfaceCreated() { |
| 85 SetTextureFormat( | 86 SetTextureFormat( |
| 86 layer_tree_host()->GetRendererCapabilities().best_texture_format); | 87 layer_tree_host()->GetRendererCapabilities().best_texture_format); |
| 87 TiledLayer::OnOutputSurfaceCreated(); | 88 TiledLayer::OnOutputSurfaceCreated(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 float ImageLayer::ImageContentsScaleX() const { | 91 float ImageLayer::ImageContentsScaleX() const { |
| 91 if (bounds().IsEmpty() || bitmap_.width() == 0) | 92 if (bounds().IsEmpty() || bitmap_.width() == 0) |
| 92 return 1; | 93 return 1; |
| 93 return static_cast<float>(bitmap_.width()) / bounds().width(); | 94 return static_cast<float>(bitmap_.width()) / bounds().width(); |
| 94 } | 95 } |
| 95 | 96 |
| 96 float ImageLayer::ImageContentsScaleY() const { | 97 float ImageLayer::ImageContentsScaleY() const { |
| 97 if (bounds().IsEmpty() || bitmap_.height() == 0) | 98 if (bounds().IsEmpty() || bitmap_.height() == 0) |
| 98 return 1; | 99 return 1; |
| 99 return static_cast<float>(bitmap_.height()) / bounds().height(); | 100 return static_cast<float>(bitmap_.height()) / bounds().height(); |
| 100 } | 101 } |
| 101 | 102 |
| 102 } // namespace cc | 103 } // namespace cc |
| OLD | NEW |