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

Unified Diff: cc/layers/scrollbar_layer_unittest.cc

Issue 150603004: Fixed rounding issue on scrollbar rasterization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added test Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: cc/layers/scrollbar_layer_unittest.cc
diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc
index 2d01af7289db11f50c91955a9dab07485f31f687..09570ac319dbc2c77cefcd138beb7c4d916e4e01 100644
--- a/cc/layers/scrollbar_layer_unittest.cc
+++ b/cc/layers/scrollbar_layer_unittest.cc
@@ -29,6 +29,9 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+using ::testing::_;
+using ::testing::Invoke;
+
namespace cc {
namespace {
@@ -766,5 +769,74 @@ TEST_F(ScaledScrollbarLayerTestResourceCreation, ScaledResourceUpload) {
TestResourceUpload(4.1f);
}
+class ScaledScrollbarLayerTestScaledRasterization : public testing::Test {
+ class MockScrollbar : public FakeScrollbar {
+ public:
+ MockScrollbar(bool paint, bool has_thumb, bool is_overlay)
+ : FakeScrollbar(paint, has_thumb, is_overlay)
+ {}
+
+ MOCK_METHOD3(PaintPart, void(SkCanvas* canvas,
+ ScrollbarPart part,
+ const gfx::Rect& content_rect));
+ };
+
+ public:
+ ScaledScrollbarLayerTestScaledRasterization()
+ : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
+
+ void TestScale(const gfx::Rect scrollbar_rect, const float test_scale) {
+ layer_tree_host_.reset(
+ new MockLayerTreeHost(&fake_client_, layer_tree_settings_));
+
+ MockScrollbar* mock_scrollbar = new MockScrollbar(false, false, false);
+ scoped_refptr<Layer> layer_tree_root = Layer::Create();
+ scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer =
+ FakePaintedScrollbarLayer::Create(false, false, layer_tree_root->id(),
+ mock_scrollbar);
+
+ layer_tree_root->AddChild(scrollbar_layer);
+
+ layer_tree_host_->SetRootLayer(layer_tree_root);
+
+ scrollbar_layer->SetBounds(scrollbar_rect.size());
+ scrollbar_layer->SetPosition(scrollbar_rect.origin());
+ scrollbar_layer->fake_scrollbar()->set_location(scrollbar_rect.origin());
+ gfx::SizeF scaled_size =
+ gfx::ScaleSize(scrollbar_layer->bounds(), test_scale, test_scale);
+ gfx::PointF scaled_location =
+ gfx::ScalePoint(scrollbar_layer->position(), test_scale, test_scale);
+ scrollbar_layer->draw_properties().content_bounds =
+ gfx::Size(scaled_size.width(), scaled_size.height());
+ scrollbar_layer->draw_properties().contents_scale_x = test_scale;
+ scrollbar_layer->draw_properties().contents_scale_y = test_scale;
+ scrollbar_layer->draw_properties().visible_content_rect =
+ gfx::Rect(scaled_location.x(),
+ scaled_location.y(),
+ scaled_size.width(),
+ scaled_size.height());
+
+ ResourceUpdateQueue queue;
+ OcclusionTracker occlusion_tracker(gfx::Rect(), false);
+ scrollbar_layer->SavePaintProperties();
+
+ EXPECT_CALL(*mock_scrollbar, PaintPart(_, TRACK, scrollbar_rect));
+
+ scrollbar_layer->Update(&queue, &occlusion_tracker);
+ scrollbar_layer->ClearRenderSurface();
+ }
+
+ protected:
+ FakeLayerTreeHostClient fake_client_;
+ LayerTreeSettings layer_tree_settings_;
+ scoped_ptr<MockLayerTreeHost> layer_tree_host_;
+};
+
+TEST_F(ScaledScrollbarLayerTestScaledRasterization, TestLostPrecisionInClip) {
+ // Try rasterization at a scale that caused problematic floating point
+ // clamping causing a black line on scrollbar edges.
+ TestScale(gfx::Rect(1117, 0, 15, 677), 7.301320);
danakj 2014/02/10 19:17:28 7.301320f
+}
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698