| 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 10 matching lines...) Expand all Loading... |
| 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
| 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebSolidColorLayer.
h" | 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebSolidColorLayer.
h" |
| 23 #include "ui/base/animation/animation.h" | 23 #include "ui/base/animation/animation.h" |
| 24 #include "ui/compositor/compositor_switches.h" | 24 #include "ui/compositor/compositor_switches.h" |
| 25 #include "ui/compositor/dip_util.h" | 25 #include "ui/compositor/dip_util.h" |
| 26 #include "ui/compositor/layer_animator.h" | 26 #include "ui/compositor/layer_animator.h" |
| 27 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
| 28 #include "ui/gfx/display.h" | 28 #include "ui/gfx/display.h" |
| 29 #include "ui/gfx/interpolated_transform.h" | 29 #include "ui/gfx/interpolated_transform.h" |
| 30 #include "ui/gfx/point3.h" | 30 #include "ui/gfx/point3.h" |
| 31 #include "ui/gfx/size_conversions.h" |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 const float EPSILON = 1e-3f; | 35 const float EPSILON = 1e-3f; |
| 35 | 36 |
| 36 bool IsApproximateMultipleOf(float value, float base) { | 37 bool IsApproximateMultipleOf(float value, float base) { |
| 37 float remainder = fmod(fabs(value), base); | 38 float remainder = fmod(fabs(value), base); |
| 38 return remainder < EPSILON || base - remainder < EPSILON; | 39 return remainder < EPSILON || base - remainder < EPSILON; |
| 39 } | 40 } |
| 40 | 41 |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 web_layer_->setDrawsContent(should_draw); | 748 web_layer_->setDrawsContent(should_draw); |
| 748 } | 749 } |
| 749 web_layer_->setBounds(ConvertSizeToPixel(this, bounds_.size())); | 750 web_layer_->setBounds(ConvertSizeToPixel(this, bounds_.size())); |
| 750 } else { | 751 } else { |
| 751 DCHECK(texture_); | 752 DCHECK(texture_); |
| 752 | 753 |
| 753 gfx::Size texture_size; | 754 gfx::Size texture_size; |
| 754 if (scale_content_) { | 755 if (scale_content_) { |
| 755 texture_size = texture_->size(); | 756 texture_size = texture_->size(); |
| 756 } else { | 757 } else { |
| 757 texture_size = | 758 texture_size = gfx::ToFlooredSize( |
| 758 texture_->size().Scale(1.0f / texture_->device_scale_factor()); | 759 texture_->size().Scale(1.0f / texture_->device_scale_factor())); |
| 759 } | 760 } |
| 760 | 761 |
| 761 gfx::Size size(std::min(bounds().width(), texture_size.width()), | 762 gfx::Size size(std::min(bounds().width(), texture_size.width()), |
| 762 std::min(bounds().height(), texture_size.height())); | 763 std::min(bounds().height(), texture_size.height())); |
| 763 WebKit::WebFloatRect rect( | 764 WebKit::WebFloatRect rect( |
| 764 0, | 765 0, |
| 765 0, | 766 0, |
| 766 static_cast<float>(size.width())/texture_size.width(), | 767 static_cast<float>(size.width())/texture_size.width(), |
| 767 static_cast<float>(size.height())/texture_size.height()); | 768 static_cast<float>(size.height())/texture_size.height()); |
| 768 texture_layer_->setUVRect(rect); | 769 texture_layer_->setUVRect(rect); |
| 769 | 770 |
| 770 gfx::Size size_in_pixel = ConvertSizeToPixel(this, size); | 771 gfx::Size size_in_pixel = ConvertSizeToPixel(this, size); |
| 771 web_layer_->setBounds(size_in_pixel); | 772 web_layer_->setBounds(size_in_pixel); |
| 772 } | 773 } |
| 773 } | 774 } |
| 774 | 775 |
| 775 void Layer::RecomputeDebugBorderColor() { | 776 void Layer::RecomputeDebugBorderColor() { |
| 776 if (!show_debug_borders_) | 777 if (!show_debug_borders_) |
| 777 return; | 778 return; |
| 778 unsigned int color = 0xFF000000; | 779 unsigned int color = 0xFF000000; |
| 779 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; | 780 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; |
| 780 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); | 781 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); |
| 781 if (!opaque) | 782 if (!opaque) |
| 782 color |= 0xFF; | 783 color |= 0xFF; |
| 783 web_layer_->setDebugBorderColor(color); | 784 web_layer_->setDebugBorderColor(color); |
| 784 } | 785 } |
| 785 | 786 |
| 786 } // namespace ui | 787 } // namespace ui |
| OLD | NEW |