OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/nine_patch_layer_impl.h" | 7 #include "cc/nine_patch_layer_impl.h" |
8 | 8 |
9 #include "cc/append_quads_data.h" | 9 #include "cc/append_quads_data.h" |
10 #include "cc/single_thread_proxy.h" | 10 #include "cc/single_thread_proxy.h" |
11 #include "cc/test/geometry_test_utils.h" | 11 #include "cc/test/geometry_test_utils.h" |
12 #include "cc/test/layer_test_common.h" | 12 #include "cc/test/layer_test_common.h" |
13 #include "cc/test/mock_quad_culler.h" | 13 #include "cc/test/mock_quad_culler.h" |
14 #include "cc/texture_draw_quad.h" | 14 #include "cc/texture_draw_quad.h" |
15 #include "ui/gfx/rect_conversions.h" | 15 #include "ui/gfx/rect_conversions.h" |
16 #include "ui/gfx/safe_integer_conversions.h" | 16 #include "ui/gfx/safe_integer_conversions.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include <public/WebTransformationMatrix.h> | 19 #include <public/WebTransformationMatrix.h> |
20 | 20 |
21 using namespace cc; | 21 namespace cc { |
22 | |
23 namespace { | 22 namespace { |
24 | 23 |
25 gfx::Rect ToRoundedIntRect(gfx::RectF rect_f) { | 24 gfx::Rect ToRoundedIntRect(gfx::RectF rect_f) { |
26 return gfx::Rect(gfx::ToRoundedInt(rect_f.x()), gfx::ToRoundedInt(rect_f.y()
), gfx::ToRoundedInt(rect_f.width()), gfx::ToRoundedInt(rect_f.height())); | 25 return gfx::Rect(gfx::ToRoundedInt(rect_f.x()), gfx::ToRoundedInt(rect_f.y()
), gfx::ToRoundedInt(rect_f.width()), gfx::ToRoundedInt(rect_f.height())); |
27 } | 26 } |
28 | 27 |
29 TEST(NinePatchLayerImplTest, verifyDrawQuads) | 28 TEST(NinePatchLayerImplTest, verifyDrawQuads) |
30 { | 29 { |
31 // Input is a 100x100 bitmap with a 40x50 aperture at x=20, y=30. | 30 // Input is a 100x100 bitmap with a 40x50 aperture at x=20, y=30. |
32 // The bounds of the layer are set to 400x400, so the draw quads | 31 // The bounds of the layer are set to 400x400, so the draw quads |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 TextureDrawQuad* texQuad = static_cast<TextureDrawQuad*>(quad); | 81 TextureDrawQuad* texQuad = static_cast<TextureDrawQuad*>(quad); |
83 gfx::RectF texRect = texQuad->uvRect(); | 82 gfx::RectF texRect = texQuad->uvRect(); |
84 texRect.Scale(bitmapSize.width(), bitmapSize.height()); | 83 texRect.Scale(bitmapSize.width(), bitmapSize.height()); |
85 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); | 84 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); |
86 } | 85 } |
87 EXPECT_RECT_EQ(texRemaining.bounds(), apertureRect); | 86 EXPECT_RECT_EQ(texRemaining.bounds(), apertureRect); |
88 Region apertureRegion(apertureRect); | 87 Region apertureRegion(apertureRect); |
89 EXPECT_EQ(texRemaining, apertureRegion); | 88 EXPECT_EQ(texRemaining, apertureRegion); |
90 } | 89 } |
91 | 90 |
92 } | 91 } // namespace |
| 92 } // namespace cc |
OLD | NEW |