Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: ui/compositor/layer.cc

Issue 10941017: Change the scale factor of texture_size from the layer's one to an estimation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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. Thus estimate the scale
759 // factor from the size of the texture and the layer.
760 // TODO(mukai): add tests.
761 float scale_factor =
762 static_cast<float>(bounds().width()) / texture_->size().width();
piman 2012/09/19 23:08:48 This will entirely defeat the purpose of computing
Jun Mukai 2012/09/20 22:00:31 Thanks for comments. Then I introduced another fi
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698