| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/compositor/layer.h" | 5 #include "ui/compositor/layer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 bool should_draw = type_ != LAYER_NOT_DRAWN; | 742 bool should_draw = type_ != LAYER_NOT_DRAWN; |
| 743 if (!web_layer_is_accelerated_) { | 743 if (!web_layer_is_accelerated_) { |
| 744 if (type_ != LAYER_SOLID_COLOR) { | 744 if (type_ != LAYER_SOLID_COLOR) { |
| 745 web_layer_->setDrawsContent(should_draw); | 745 web_layer_->setDrawsContent(should_draw); |
| 746 } | 746 } |
| 747 web_layer_->setBounds(ConvertSizeToPixel(this, bounds_.size())); | 747 web_layer_->setBounds(ConvertSizeToPixel(this, bounds_.size())); |
| 748 } else { | 748 } else { |
| 749 DCHECK(texture_); | 749 DCHECK(texture_); |
| 750 | 750 |
| 751 gfx::Size texture_size; | 751 gfx::Size texture_size; |
| 752 if (scale_content_) | 752 if (scale_content_) { |
| 753 texture_size = texture_->size(); | 753 texture_size = texture_->size(); |
| 754 else | 754 } else { |
| 755 texture_size = ConvertSizeToDIP(this, texture_->size()); | 755 texture_size = |
| 756 texture_->size().Scale(1.0f / texture_->device_scale_factor()); |
| 757 } |
| 756 | 758 |
| 757 gfx::Size size(std::min(bounds().width(), texture_size.width()), | 759 gfx::Size size(std::min(bounds().width(), texture_size.width()), |
| 758 std::min(bounds().height(), texture_size.height())); | 760 std::min(bounds().height(), texture_size.height())); |
| 759 WebKit::WebFloatRect rect( | 761 WebKit::WebFloatRect rect( |
| 760 0, | 762 0, |
| 761 0, | 763 0, |
| 762 static_cast<float>(size.width())/texture_size.width(), | 764 static_cast<float>(size.width())/texture_size.width(), |
| 763 static_cast<float>(size.height())/texture_size.height()); | 765 static_cast<float>(size.height())/texture_size.height()); |
| 764 texture_layer_->setUVRect(rect); | 766 texture_layer_->setUVRect(rect); |
| 765 | 767 |
| 766 gfx::Size size_in_pixel = ConvertSizeToPixel(this, size); | 768 gfx::Size size_in_pixel = ConvertSizeToPixel(this, size); |
| 767 web_layer_->setBounds(size_in_pixel); | 769 web_layer_->setBounds(size_in_pixel); |
| 768 } | 770 } |
| 769 } | 771 } |
| 770 | 772 |
| 771 void Layer::RecomputeDebugBorderColor() { | 773 void Layer::RecomputeDebugBorderColor() { |
| 772 if (!show_debug_borders_) | 774 if (!show_debug_borders_) |
| 773 return; | 775 return; |
| 774 unsigned int color = 0xFF000000; | 776 unsigned int color = 0xFF000000; |
| 775 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; | 777 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; |
| 776 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); | 778 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); |
| 777 if (!opaque) | 779 if (!opaque) |
| 778 color |= 0xFF; | 780 color |= 0xFF; |
| 779 web_layer_->setDebugBorderColor(color); | 781 web_layer_->setDebugBorderColor(color); |
| 780 } | 782 } |
| 781 | 783 |
| 782 } // namespace ui | 784 } // namespace ui |
| OLD | NEW |