summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-13 05:36:59 +0000
committerenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-13 05:36:59 +0000
commitdef73e99ea8a41dd98d2ed0a885dbe8a6d9a26d2 (patch)
tree4efef05526813b300b2577cedb72cfb28121db07
parent5b3a8e0d883a0fb89faa1b23992c9dcaea9ea44d (diff)
downloadchromium_src-def73e99ea8a41dd98d2ed0a885dbe8a6d9a26d2.zip
chromium_src-def73e99ea8a41dd98d2ed0a885dbe8a6d9a26d2.tar.gz
chromium_src-def73e99ea8a41dd98d2ed0a885dbe8a6d9a26d2.tar.bz2
cc: Chromify ContentsScalingLayer and test
R=danakj@chromium.org BUG=none Review URL: https://chromiumcodereview.appspot.com/12808002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187791 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/contents_scaling_layer.cc16
-rw-r--r--cc/contents_scaling_layer.h2
-rw-r--r--cc/contents_scaling_layer_unittest.cc83
-rw-r--r--cc/scrollbar_layer.cc2
4 files changed, 50 insertions, 53 deletions
diff --git a/cc/contents_scaling_layer.cc b/cc/contents_scaling_layer.cc
index f91d9c4..3b72d3f 100644
--- a/cc/contents_scaling_layer.cc
+++ b/cc/contents_scaling_layer.cc
@@ -7,15 +7,15 @@
namespace cc {
-gfx::Size ContentsScalingLayer::computeContentBoundsForScale(float scaleX, float scaleY) const {
- return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scaleX, scaleY));
+gfx::Size ContentsScalingLayer::ComputeContentBoundsForScale(
+ float scale_x,
+ float scale_y) const {
+ return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scale_x, scale_y));
}
ContentsScalingLayer::ContentsScalingLayer()
- : last_update_contents_scale_x_(0.f)
- , last_update_contents_scale_y_(0.f)
- {
-}
+ : last_update_contents_scale_x_(0.f),
+ last_update_contents_scale_y_(0.f) {}
ContentsScalingLayer::~ContentsScalingLayer() {
}
@@ -28,7 +28,7 @@ void ContentsScalingLayer::CalculateContentsScale(
gfx::Size* content_bounds) {
*contents_scale_x = ideal_contents_scale;
*contents_scale_y = ideal_contents_scale;
- *content_bounds = computeContentBoundsForScale(
+ *content_bounds = ComputeContentBoundsForScale(
ideal_contents_scale,
ideal_contents_scale);
}
@@ -40,7 +40,7 @@ void ContentsScalingLayer::Update(
if (draw_properties().contents_scale_x == last_update_contents_scale_x_ &&
draw_properties().contents_scale_y == last_update_contents_scale_y_)
return;
-
+
last_update_contents_scale_x_ = draw_properties().contents_scale_x;
last_update_contents_scale_y_ = draw_properties().contents_scale_y;
// Invalidate the whole layer if scale changed.
diff --git a/cc/contents_scaling_layer.h b/cc/contents_scaling_layer.h
index d31bde8..44d3fe7 100644
--- a/cc/contents_scaling_layer.h
+++ b/cc/contents_scaling_layer.h
@@ -30,7 +30,7 @@ class CC_EXPORT ContentsScalingLayer : public Layer {
ContentsScalingLayer();
virtual ~ContentsScalingLayer();
- gfx::Size computeContentBoundsForScale(float scaleX, float scaleY) const;
+ gfx::Size ComputeContentBoundsForScale(float scale_x, float scale_y) const;
private:
float last_update_contents_scale_x_;
diff --git a/cc/contents_scaling_layer_unittest.cc b/cc/contents_scaling_layer_unittest.cc
index cde56ea..2c350fc 100644
--- a/cc/contents_scaling_layer_unittest.cc
+++ b/cc/contents_scaling_layer_unittest.cc
@@ -13,26 +13,25 @@ namespace {
class MockContentsScalingLayer : public ContentsScalingLayer {
public:
MockContentsScalingLayer()
- : ContentsScalingLayer() {
- }
+ : ContentsScalingLayer() {}
- virtual void SetNeedsDisplayRect(const gfx::RectF& dirtyRect) OVERRIDE {
- m_lastNeedsDisplayRect = dirtyRect;
- ContentsScalingLayer::SetNeedsDisplayRect(dirtyRect);
+ virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) OVERRIDE {
+ last_needs_display_rect_ = dirty_rect;
+ ContentsScalingLayer::SetNeedsDisplayRect(dirty_rect);
}
- void resetNeedsDisplay() {
+ void ResetNeedsDisplay() {
needs_display_ = false;
}
- const gfx::RectF& lastNeedsDisplayRect() const {
- return m_lastNeedsDisplayRect;
+ const gfx::RectF& LastNeedsDisplayRect() const {
+ return last_needs_display_rect_;
}
- void updateContentsScale(float contentsScale) {
- // Simulate calcDrawProperties.
+ void UpdateContentsScale(float contents_scale) {
+ // Simulate CalcDrawProperties.
CalculateContentsScale(
- contentsScale,
+ contents_scale,
false, // animating_transform_to_screen
&draw_properties().contents_scale_x,
&draw_properties().contents_scale_y,
@@ -40,51 +39,49 @@ class MockContentsScalingLayer : public ContentsScalingLayer {
}
private:
- virtual ~MockContentsScalingLayer() {
- }
+ virtual ~MockContentsScalingLayer() {}
- gfx::RectF m_lastNeedsDisplayRect;
+ gfx::RectF last_needs_display_rect_;
};
-void calcDrawProps(Layer* root, float deviceScale)
-{
- std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
+void CalcDrawProps(Layer* root, float device_scale) {
+ std::vector<scoped_refptr<Layer> > render_surface_layer_list;
LayerTreeHostCommon::calculateDrawProperties(
root,
gfx::Size(500, 500),
- deviceScale,
- 1,
+ device_scale,
+ 1.f,
1024,
false,
- renderSurfaceLayerList);
+ render_surface_layer_list);
}
-TEST(ContentsScalingLayerTest, checkContentsBounds) {
- scoped_refptr<MockContentsScalingLayer> testLayer =
+TEST(ContentsScalingLayerTest, CheckContentsBounds) {
+ scoped_refptr<MockContentsScalingLayer> test_layer =
make_scoped_refptr(new MockContentsScalingLayer());
scoped_refptr<Layer> root = Layer::Create();
- root->AddChild(testLayer);
-
- testLayer->SetBounds(gfx::Size(320, 240));
- calcDrawProps(root, 1.0);
- EXPECT_FLOAT_EQ(1.0, testLayer->contents_scale_x());
- EXPECT_FLOAT_EQ(1.0, testLayer->contents_scale_y());
- EXPECT_EQ(320, testLayer->content_bounds().width());
- EXPECT_EQ(240, testLayer->content_bounds().height());
-
- calcDrawProps(root, 2.0);
- EXPECT_EQ(640, testLayer->content_bounds().width());
- EXPECT_EQ(480, testLayer->content_bounds().height());
-
- testLayer->SetBounds(gfx::Size(10, 20));
- calcDrawProps(root, 2.0);
- EXPECT_EQ(20, testLayer->content_bounds().width());
- EXPECT_EQ(40, testLayer->content_bounds().height());
-
- calcDrawProps(root, 1.33f);
- EXPECT_EQ(14, testLayer->content_bounds().width());
- EXPECT_EQ(27, testLayer->content_bounds().height());
+ root->AddChild(test_layer);
+
+ test_layer->SetBounds(gfx::Size(320, 240));
+ CalcDrawProps(root, 1.f);
+ EXPECT_FLOAT_EQ(1.f, test_layer->contents_scale_x());
+ EXPECT_FLOAT_EQ(1.f, test_layer->contents_scale_y());
+ EXPECT_EQ(320, test_layer->content_bounds().width());
+ EXPECT_EQ(240, test_layer->content_bounds().height());
+
+ CalcDrawProps(root, 2.f);
+ EXPECT_EQ(640, test_layer->content_bounds().width());
+ EXPECT_EQ(480, test_layer->content_bounds().height());
+
+ test_layer->SetBounds(gfx::Size(10, 20));
+ CalcDrawProps(root, 2.f);
+ EXPECT_EQ(20, test_layer->content_bounds().width());
+ EXPECT_EQ(40, test_layer->content_bounds().height());
+
+ CalcDrawProps(root, 1.33f);
+ EXPECT_EQ(14, test_layer->content_bounds().width());
+ EXPECT_EQ(27, test_layer->content_bounds().height());
}
} // namespace
diff --git a/cc/scrollbar_layer.cc b/cc/scrollbar_layer.cc
index 3d83aeb..9debbf9 100644
--- a/cc/scrollbar_layer.cc
+++ b/cc/scrollbar_layer.cc
@@ -77,7 +77,7 @@ float ScrollbarLayer::ClampScaleToMaxTextureSize(float scale) {
// If the scaled content_bounds() is bigger than the max texture size of the
// device, we need to clamp it by rescaling, since content_bounds() is used
// below to set the texture size.
- gfx::Size scaled_bounds = computeContentBoundsForScale(scale, scale);
+ gfx::Size scaled_bounds = ComputeContentBoundsForScale(scale, scale);
if (scaled_bounds.width() > MaxTextureSize() ||
scaled_bounds.height() > MaxTextureSize()) {
if (scaled_bounds.width() > scaled_bounds.height())