OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/android/compositor/layer/contextual_search_layer.h" | 5 #include "chrome/browser/android/compositor/layer/contextual_search_layer.h" |
6 | 6 |
7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
8 #include "cc/layers/nine_patch_layer.h" | 8 #include "cc/layers/nine_patch_layer.h" |
9 #include "cc/layers/solid_color_layer.h" | 9 #include "cc/layers/solid_color_layer.h" |
10 #include "cc/layers/ui_resource_layer.h" | 10 #include "cc/layers/ui_resource_layer.h" |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 // either the original |thumbnail| height or width is smaller than | 697 // either the original |thumbnail| height or width is smaller than |
698 // |bar_image_size_|, the thumbnail will not be scaled. | 698 // |bar_image_size_|, the thumbnail will not be scaled. |
699 int layer_width = std::min(bar_image_size_, scaled_thumbnail_width); | 699 int layer_width = std::min(bar_image_size_, scaled_thumbnail_width); |
700 int layer_height = std::min(bar_image_size_, scaled_thumbnail_height); | 700 int layer_height = std::min(bar_image_size_, scaled_thumbnail_height); |
701 | 701 |
702 // UIResourceLayer requires an immutable copy of the input |thumbnail|. | 702 // UIResourceLayer requires an immutable copy of the input |thumbnail|. |
703 SkBitmap thumbnail_copy; | 703 SkBitmap thumbnail_copy; |
704 if (thumbnail->isImmutable()) { | 704 if (thumbnail->isImmutable()) { |
705 thumbnail_copy = *thumbnail; | 705 thumbnail_copy = *thumbnail; |
706 } else { | 706 } else { |
707 thumbnail->copyTo(&thumbnail_copy); | 707 if (thumbnail_copy.tryAllocPixels(thumbnail->info())) { |
| 708 thumbnail->readPixels(thumbnail_copy.info(), thumbnail_copy.getPixels(), |
| 709 thumbnail_copy.rowBytes(), 0, 0); |
| 710 } |
708 thumbnail_copy.setImmutable(); | 711 thumbnail_copy.setImmutable(); |
709 } | 712 } |
710 | 713 |
711 thumbnail_layer_->SetBitmap(thumbnail_copy); | 714 thumbnail_layer_->SetBitmap(thumbnail_copy); |
712 thumbnail_layer_->SetBounds(gfx::Size(layer_width, layer_height)); | 715 thumbnail_layer_->SetBounds(gfx::Size(layer_width, layer_height)); |
713 thumbnail_layer_->SetPosition( | 716 thumbnail_layer_->SetPosition( |
714 gfx::PointF(thumbnail_side_margin_, thumbnail_top_margin_)); | 717 gfx::PointF(thumbnail_side_margin_, thumbnail_top_margin_)); |
715 thumbnail_layer_->SetUV(gfx::PointF(top_left_x, top_left_y), | 718 thumbnail_layer_->SetUV(gfx::PointF(top_left_x, top_left_y), |
716 gfx::PointF(bottom_right_x, bottom_right_y)); | 719 gfx::PointF(bottom_right_x, bottom_right_y)); |
717 } | 720 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 | 795 |
793 // Touch Highlight Layer | 796 // Touch Highlight Layer |
794 touch_highlight_layer_->SetIsDrawable(true); | 797 touch_highlight_layer_->SetIsDrawable(true); |
795 touch_highlight_layer_->SetBackgroundColor(kTouchHighlightColor); | 798 touch_highlight_layer_->SetBackgroundColor(kTouchHighlightColor); |
796 } | 799 } |
797 | 800 |
798 ContextualSearchLayer::~ContextualSearchLayer() { | 801 ContextualSearchLayer::~ContextualSearchLayer() { |
799 } | 802 } |
800 | 803 |
801 } // namespace android | 804 } // namespace android |
OLD | NEW |