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 <stdio.h> | 5 #include <stdio.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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 EXPECT_RECT_EQ(scaledApertureNonUniform, remaining.bounds()); | 75 EXPECT_RECT_EQ(scaledApertureNonUniform, remaining.bounds()); |
76 Region scaledApertureRegion(scaledApertureNonUniform); | 76 Region scaledApertureRegion(scaledApertureNonUniform); |
77 EXPECT_EQ(scaledApertureRegion, remaining); | 77 EXPECT_EQ(scaledApertureRegion, remaining); |
78 | 78 |
79 // Verify UV rects | 79 // Verify UV rects |
80 gfx::Rect bitmapRect(gfx::Point(), bitmapSize); | 80 gfx::Rect bitmapRect(gfx::Point(), bitmapSize); |
81 Region texRemaining(bitmapRect); | 81 Region texRemaining(bitmapRect); |
82 for (size_t i = 0; i < quads.size(); ++i) { | 82 for (size_t i = 0; i < quads.size(); ++i) { |
83 DrawQuad* quad = quads[i]; | 83 DrawQuad* quad = quads[i]; |
84 const TextureDrawQuad* texQuad = TextureDrawQuad::MaterialCast(quad); | 84 const TextureDrawQuad* texQuad = TextureDrawQuad::MaterialCast(quad); |
85 gfx::RectF texRect = texQuad->uv_rect; | 85 gfx::SizeF uvSize(texQuad->uv_bottom_right.x() - texQuad->uv_top_left.x( ), |
86 texQuad->uv_bottom_right.y() - texQuad->uv_top_left.y( )); | |
87 gfx::RectF texRect(texQuad->uv_top_left, uvSize); | |
danakj
2013/01/11 02:21:51
you can use this from rect_f.h
UI_EXPORT RectF Bo
Jerome
2013/01/11 18:00:01
Done.
| |
86 texRect.Scale(bitmapSize.width(), bitmapSize.height()); | 88 texRect.Scale(bitmapSize.width(), bitmapSize.height()); |
87 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); | 89 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); |
88 } | 90 } |
89 EXPECT_RECT_EQ(apertureRect, texRemaining.bounds()); | 91 EXPECT_RECT_EQ(apertureRect, texRemaining.bounds()); |
90 Region apertureRegion(apertureRect); | 92 Region apertureRegion(apertureRect); |
91 EXPECT_EQ(apertureRegion, texRemaining); | 93 EXPECT_EQ(apertureRegion, texRemaining); |
92 } | 94 } |
93 | 95 |
94 TEST(NinePatchLayerImplTest, verifyDrawQuadsForSqueezedLayer) | 96 TEST(NinePatchLayerImplTest, verifyDrawQuadsForSqueezedLayer) |
95 { | 97 { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 Region expectedFull(visibleContentRect); | 130 Region expectedFull(visibleContentRect); |
129 EXPECT_EQ(expectedFull, filled); | 131 EXPECT_EQ(expectedFull, filled); |
130 | 132 |
131 // Verify UV rects cover the corners of the bitmap and the crop is weighted | 133 // Verify UV rects cover the corners of the bitmap and the crop is weighted |
132 // proportionately to the relative corner sizes (for uneven apertures). | 134 // proportionately to the relative corner sizes (for uneven apertures). |
133 gfx::Rect bitmapRect(gfx::Point(), bitmapSize); | 135 gfx::Rect bitmapRect(gfx::Point(), bitmapSize); |
134 Region texRemaining(bitmapRect); | 136 Region texRemaining(bitmapRect); |
135 for (size_t i = 0; i < quads.size(); ++i) { | 137 for (size_t i = 0; i < quads.size(); ++i) { |
136 DrawQuad* quad = quads[i]; | 138 DrawQuad* quad = quads[i]; |
137 const TextureDrawQuad* texQuad = TextureDrawQuad::MaterialCast(quad); | 139 const TextureDrawQuad* texQuad = TextureDrawQuad::MaterialCast(quad); |
138 gfx::RectF texRect = texQuad->uv_rect; | 140 gfx::SizeF uvSize(texQuad->uv_bottom_right.x() - texQuad->uv_top_left.x( ), |
141 texQuad->uv_bottom_right.y() - texQuad->uv_top_left.y( )); | |
142 gfx::RectF texRect(texQuad->uv_top_left, uvSize); | |
danakj
2013/01/11 02:21:51
same here
Jerome
2013/01/11 18:00:01
Done.
| |
139 texRect.Scale(bitmapSize.width(), bitmapSize.height()); | 143 texRect.Scale(bitmapSize.width(), bitmapSize.height()); |
140 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); | 144 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); |
141 } | 145 } |
142 Region expectedRemainingRegion = Region(gfx::Rect(bitmapSize)); | 146 Region expectedRemainingRegion = Region(gfx::Rect(bitmapSize)); |
143 expectedRemainingRegion.Subtract(gfx::Rect(0, 0, 17, 28)); | 147 expectedRemainingRegion.Subtract(gfx::Rect(0, 0, 17, 28)); |
144 expectedRemainingRegion.Subtract(gfx::Rect(67, 0, 34, 28)); | 148 expectedRemainingRegion.Subtract(gfx::Rect(67, 0, 34, 28)); |
145 expectedRemainingRegion.Subtract(gfx::Rect(0, 78, 17, 23)); | 149 expectedRemainingRegion.Subtract(gfx::Rect(0, 78, 17, 23)); |
146 expectedRemainingRegion.Subtract(gfx::Rect(67, 78, 34, 23)); | 150 expectedRemainingRegion.Subtract(gfx::Rect(67, 78, 34, 23)); |
147 EXPECT_EQ(expectedRemainingRegion, texRemaining); | 151 EXPECT_EQ(expectedRemainingRegion, texRemaining); |
148 } | 152 } |
149 | 153 |
150 } // namespace | 154 } // namespace |
151 } // namespace cc | 155 } // namespace cc |
OLD | NEW |