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" |
(...skipping 10 matching lines...) Expand all Loading... |
21 using namespace cc; | 21 using namespace cc; |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 gfx::Rect ToRoundedIntRect(gfx::RectF rect_f) { | 25 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())); | 26 return gfx::Rect(gfx::ToRoundedInt(rect_f.x()), gfx::ToRoundedInt(rect_f.y()
), gfx::ToRoundedInt(rect_f.width()), gfx::ToRoundedInt(rect_f.height())); |
27 } | 27 } |
28 | 28 |
29 TEST(NinePatchLayerImplTest, verifyDrawQuads) | 29 TEST(NinePatchLayerImplTest, verifyDrawQuads) |
30 { | 30 { |
31 DebugScopedSetImplThread implThread; | |
32 | |
33 // Input is a 100x100 bitmap with a 40x50 aperture at x=20, y=30. | 31 // Input is a 100x100 bitmap with a 40x50 aperture at x=20, y=30. |
34 // The bounds of the layer are set to 400x400, so the draw quads | 32 // The bounds of the layer are set to 400x400, so the draw quads |
35 // generated should leave the border width (40) intact. | 33 // generated should leave the border width (40) intact. |
36 MockQuadCuller quadCuller; | 34 MockQuadCuller quadCuller; |
37 gfx::Size bitmapSize(100, 100); | 35 gfx::Size bitmapSize(100, 100); |
38 gfx::Size layerSize(400, 400); | 36 gfx::Size layerSize(400, 400); |
39 gfx::Rect visibleContentRect(gfx::Point(), layerSize); | 37 gfx::Rect visibleContentRect(gfx::Point(), layerSize); |
40 gfx::Rect apertureRect(20, 30, 40, 50); | 38 gfx::Rect apertureRect(20, 30, 40, 50); |
41 gfx::Rect scaledApertureNonUniform(20, 30, 340, 350); | 39 gfx::Rect scaledApertureNonUniform(20, 30, 340, 350); |
42 | 40 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 gfx::RectF texRect = texQuad->uvRect(); | 83 gfx::RectF texRect = texQuad->uvRect(); |
86 texRect.Scale(bitmapSize.width(), bitmapSize.height()); | 84 texRect.Scale(bitmapSize.width(), bitmapSize.height()); |
87 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); | 85 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); |
88 } | 86 } |
89 EXPECT_RECT_EQ(texRemaining.bounds(), apertureRect); | 87 EXPECT_RECT_EQ(texRemaining.bounds(), apertureRect); |
90 Region apertureRegion(apertureRect); | 88 Region apertureRegion(apertureRect); |
91 EXPECT_EQ(texRemaining, apertureRegion); | 89 EXPECT_EQ(texRemaining, apertureRegion); |
92 } | 90 } |
93 | 91 |
94 } | 92 } |
OLD | NEW |