| 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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 DCHECK(web_layer_); | 760 DCHECK(web_layer_); |
| 761 bool should_draw = type_ != LAYER_NOT_DRAWN; | 761 bool should_draw = type_ != LAYER_NOT_DRAWN; |
| 762 if (!web_layer_is_accelerated_) { | 762 if (!web_layer_is_accelerated_) { |
| 763 if (type_ != LAYER_SOLID_COLOR) { | 763 if (type_ != LAYER_SOLID_COLOR) { |
| 764 web_layer_->setDrawsContent(should_draw); | 764 web_layer_->setDrawsContent(should_draw); |
| 765 } | 765 } |
| 766 web_layer_->setBounds(ConvertSizeToPixel(this, bounds_.size())); | 766 web_layer_->setBounds(ConvertSizeToPixel(this, bounds_.size())); |
| 767 } else { | 767 } else { |
| 768 DCHECK(texture_); | 768 DCHECK(texture_); |
| 769 | 769 |
| 770 float texture_scale_factor = 1.0f / texture_->device_scale_factor(); |
| 770 gfx::Size texture_size = gfx::ToFlooredSize( | 771 gfx::Size texture_size = gfx::ToFlooredSize( |
| 771 texture_->size().Scale(1.0f / texture_->device_scale_factor())); | 772 gfx::ScaleSize(texture_->size(), texture_scale_factor)); |
| 772 | 773 |
| 773 gfx::Size size(std::min(bounds().width(), texture_size.width()), | 774 gfx::Size size(std::min(bounds().width(), texture_size.width()), |
| 774 std::min(bounds().height(), texture_size.height())); | 775 std::min(bounds().height(), texture_size.height())); |
| 775 WebKit::WebFloatRect rect( | 776 WebKit::WebFloatRect rect( |
| 776 0, | 777 0, |
| 777 0, | 778 0, |
| 778 static_cast<float>(size.width())/texture_size.width(), | 779 static_cast<float>(size.width())/texture_size.width(), |
| 779 static_cast<float>(size.height())/texture_size.height()); | 780 static_cast<float>(size.height())/texture_size.height()); |
| 780 texture_layer_->setUVRect(rect); | 781 texture_layer_->setUVRect(rect); |
| 781 | 782 |
| 782 gfx::Size size_in_pixel = ConvertSizeToPixel(this, size); | 783 gfx::Size size_in_pixel = ConvertSizeToPixel(this, size); |
| 783 web_layer_->setBounds(size_in_pixel); | 784 web_layer_->setBounds(size_in_pixel); |
| 784 } | 785 } |
| 785 } | 786 } |
| 786 | 787 |
| 787 void Layer::RecomputeDebugBorderColor() { | 788 void Layer::RecomputeDebugBorderColor() { |
| 788 if (!show_debug_borders_) | 789 if (!show_debug_borders_) |
| 789 return; | 790 return; |
| 790 unsigned int color = 0xFF000000; | 791 unsigned int color = 0xFF000000; |
| 791 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; | 792 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; |
| 792 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); | 793 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); |
| 793 if (!opaque) | 794 if (!opaque) |
| 794 color |= 0xFF; | 795 color |= 0xFF; |
| 795 web_layer_->setDebugBorderColor(color); | 796 web_layer_->setDebugBorderColor(color); |
| 796 } | 797 } |
| 797 | 798 |
| 798 } // namespace ui | 799 } // namespace ui |
| OLD | NEW |