| 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::RectF texRect = gfx::BoundingRect(texQuad->uv_top_left, texQuad->uv
_bottom_right); |
| 86 texRect.Scale(bitmapSize.width(), bitmapSize.height()); | 86 texRect.Scale(bitmapSize.width(), bitmapSize.height()); |
| 87 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); | 87 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); |
| 88 } | 88 } |
| 89 EXPECT_RECT_EQ(apertureRect, texRemaining.bounds()); | 89 EXPECT_RECT_EQ(apertureRect, texRemaining.bounds()); |
| 90 Region apertureRegion(apertureRect); | 90 Region apertureRegion(apertureRect); |
| 91 EXPECT_EQ(apertureRegion, texRemaining); | 91 EXPECT_EQ(apertureRegion, texRemaining); |
| 92 } | 92 } |
| 93 | 93 |
| 94 TEST(NinePatchLayerImplTest, verifyDrawQuadsForSqueezedLayer) | 94 TEST(NinePatchLayerImplTest, verifyDrawQuadsForSqueezedLayer) |
| 95 { | 95 { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 Region expectedFull(visibleContentRect); | 128 Region expectedFull(visibleContentRect); |
| 129 EXPECT_EQ(expectedFull, filled); | 129 EXPECT_EQ(expectedFull, filled); |
| 130 | 130 |
| 131 // Verify UV rects cover the corners of the bitmap and the crop is weighted | 131 // Verify UV rects cover the corners of the bitmap and the crop is weighted |
| 132 // proportionately to the relative corner sizes (for uneven apertures). | 132 // proportionately to the relative corner sizes (for uneven apertures). |
| 133 gfx::Rect bitmapRect(gfx::Point(), bitmapSize); | 133 gfx::Rect bitmapRect(gfx::Point(), bitmapSize); |
| 134 Region texRemaining(bitmapRect); | 134 Region texRemaining(bitmapRect); |
| 135 for (size_t i = 0; i < quads.size(); ++i) { | 135 for (size_t i = 0; i < quads.size(); ++i) { |
| 136 DrawQuad* quad = quads[i]; | 136 DrawQuad* quad = quads[i]; |
| 137 const TextureDrawQuad* texQuad = TextureDrawQuad::MaterialCast(quad); | 137 const TextureDrawQuad* texQuad = TextureDrawQuad::MaterialCast(quad); |
| 138 gfx::RectF texRect = texQuad->uv_rect; | 138 gfx::RectF texRect = gfx::BoundingRect(texQuad->uv_top_left, texQuad->uv
_bottom_right); |
| 139 texRect.Scale(bitmapSize.width(), bitmapSize.height()); | 139 texRect.Scale(bitmapSize.width(), bitmapSize.height()); |
| 140 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); | 140 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); |
| 141 } | 141 } |
| 142 Region expectedRemainingRegion = Region(gfx::Rect(bitmapSize)); | 142 Region expectedRemainingRegion = Region(gfx::Rect(bitmapSize)); |
| 143 expectedRemainingRegion.Subtract(gfx::Rect(0, 0, 17, 28)); | 143 expectedRemainingRegion.Subtract(gfx::Rect(0, 0, 17, 28)); |
| 144 expectedRemainingRegion.Subtract(gfx::Rect(67, 0, 34, 28)); | 144 expectedRemainingRegion.Subtract(gfx::Rect(67, 0, 34, 28)); |
| 145 expectedRemainingRegion.Subtract(gfx::Rect(0, 78, 17, 23)); | 145 expectedRemainingRegion.Subtract(gfx::Rect(0, 78, 17, 23)); |
| 146 expectedRemainingRegion.Subtract(gfx::Rect(67, 78, 34, 23)); | 146 expectedRemainingRegion.Subtract(gfx::Rect(67, 78, 34, 23)); |
| 147 EXPECT_EQ(expectedRemainingRegion, texRemaining); | 147 EXPECT_EQ(expectedRemainingRegion, texRemaining); |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace | 150 } // namespace |
| 151 } // namespace cc | 151 } // namespace cc |
| OLD | NEW |