Chromium Code Reviews| 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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 bool should_draw = type_ != LAYER_NOT_DRAWN; | 744 bool should_draw = type_ != LAYER_NOT_DRAWN; |
| 745 if (!web_layer_is_accelerated_) { | 745 if (!web_layer_is_accelerated_) { |
| 746 if (type_ != LAYER_SOLID_COLOR) { | 746 if (type_ != LAYER_SOLID_COLOR) { |
| 747 web_layer_->setDrawsContent(should_draw); | 747 web_layer_->setDrawsContent(should_draw); |
| 748 } | 748 } |
| 749 web_layer_->setBounds(ConvertSizeToPixel(this, bounds_.size())); | 749 web_layer_->setBounds(ConvertSizeToPixel(this, bounds_.size())); |
| 750 } else { | 750 } else { |
| 751 DCHECK(texture_); | 751 DCHECK(texture_); |
| 752 | 752 |
| 753 gfx::Size texture_size; | 753 gfx::Size texture_size; |
| 754 if (scale_content_) | 754 if (scale_content_) { |
| 755 texture_size = texture_->size(); | 755 texture_size = texture_->size(); |
| 756 else | 756 } else { |
| 757 texture_size = ConvertSizeToDIP(this, texture_->size()); | 757 // Scale the texture's size but the layer's scale factor can be different |
| 758 // from the one of the texture in some cases, such like phantom windows | |
| 759 // on a hi-DPI device while its original window is in a normal DPI. Thus | |
| 760 // estimate the scale factor from the size of the texture and the layer. | |
|
oshima
2012/09/18 21:20:45
can you update the comment to be more generic (wit
Jun Mukai
2012/09/19 19:26:56
Removed that part.
| |
| 761 float scale_factor = | |
| 762 static_cast<float>(bounds().width()) / texture_->size().width(); | |
| 763 texture_size = texture_->size().Scale(scale_factor); | |
| 764 } | |
| 758 | 765 |
| 759 gfx::Size size(std::min(bounds().width(), texture_size.width()), | 766 gfx::Size size(std::min(bounds().width(), texture_size.width()), |
| 760 std::min(bounds().height(), texture_size.height())); | 767 std::min(bounds().height(), texture_size.height())); |
| 761 WebKit::WebFloatRect rect( | 768 WebKit::WebFloatRect rect( |
| 762 0, | 769 0, |
| 763 0, | 770 0, |
| 764 static_cast<float>(size.width())/texture_size.width(), | 771 static_cast<float>(size.width())/texture_size.width(), |
| 765 static_cast<float>(size.height())/texture_size.height()); | 772 static_cast<float>(size.height())/texture_size.height()); |
| 766 texture_layer_->setUVRect(rect); | 773 texture_layer_->setUVRect(rect); |
| 767 | 774 |
| 768 gfx::Size size_in_pixel = ConvertSizeToPixel(this, size); | 775 gfx::Size size_in_pixel = ConvertSizeToPixel(this, size); |
| 769 web_layer_->setBounds(size_in_pixel); | 776 web_layer_->setBounds(size_in_pixel); |
| 770 } | 777 } |
| 771 } | 778 } |
| 772 | 779 |
| 773 void Layer::RecomputeDebugBorderColor() { | 780 void Layer::RecomputeDebugBorderColor() { |
| 774 if (!show_debug_borders_) | 781 if (!show_debug_borders_) |
| 775 return; | 782 return; |
| 776 unsigned int color = 0xFF000000; | 783 unsigned int color = 0xFF000000; |
| 777 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; | 784 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; |
| 778 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); | 785 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); |
| 779 if (!opaque) | 786 if (!opaque) |
| 780 color |= 0xFF; | 787 color |= 0xFF; |
| 781 web_layer_->setDebugBorderColor(color); | 788 web_layer_->setDebugBorderColor(color); |
| 782 } | 789 } |
| 783 | 790 |
| 784 } // namespace ui | 791 } // namespace ui |
| OLD | NEW |