| 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 "cc/nine_patch_layer_impl.h" | 5 #include "cc/nine_patch_layer_impl.h" |
| 6 | 6 |
| 7 #include "cc/append_quads_data.h" | 7 #include "cc/append_quads_data.h" |
| 8 #include "cc/single_thread_proxy.h" | 8 #include "cc/single_thread_proxy.h" |
| 9 #include "cc/test/geometry_test_utils.h" | 9 #include "cc/test/geometry_test_utils.h" |
| 10 #include "cc/test/layer_test_common.h" | 10 #include "cc/test/layer_test_common.h" |
| 11 #include "cc/test/mock_quad_culler.h" | 11 #include "cc/test/mock_quad_culler.h" |
| 12 #include "cc/texture_draw_quad.h" | 12 #include "cc/texture_draw_quad.h" |
| 13 #include "ui/gfx/rect_conversions.h" | 13 #include "ui/gfx/rect_conversions.h" |
| 14 #include "ui/gfx/safe_integer_conversions.h" | 14 #include "ui/gfx/safe_integer_conversions.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include <public/WebTransformationMatrix.h> | 17 #include "ui/gfx/transform.h" |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 gfx::Rect ToRoundedIntRect(gfx::RectF rect_f) { | 22 gfx::Rect ToRoundedIntRect(gfx::RectF rect_f) { |
| 23 return gfx::Rect(gfx::ToRoundedInt(rect_f.x()), gfx::ToRoundedInt(rect_f.y()
), gfx::ToRoundedInt(rect_f.width()), gfx::ToRoundedInt(rect_f.height())); | 23 return gfx::Rect(gfx::ToRoundedInt(rect_f.x()), gfx::ToRoundedInt(rect_f.y()
), gfx::ToRoundedInt(rect_f.width()), gfx::ToRoundedInt(rect_f.height())); |
| 24 } | 24 } |
| 25 | 25 |
| 26 TEST(NinePatchLayerImplTest, verifyDrawQuads) | 26 TEST(NinePatchLayerImplTest, verifyDrawQuads) |
| 27 { | 27 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 39 layer->setVisibleContentRect(visibleContentRect); | 39 layer->setVisibleContentRect(visibleContentRect); |
| 40 layer->setBounds(layerSize); | 40 layer->setBounds(layerSize); |
| 41 layer->setContentBounds(layerSize); | 41 layer->setContentBounds(layerSize); |
| 42 layer->createRenderSurface(); | 42 layer->createRenderSurface(); |
| 43 layer->setRenderTarget(layer.get()); | 43 layer->setRenderTarget(layer.get()); |
| 44 layer->setLayout(bitmapSize, apertureRect); | 44 layer->setLayout(bitmapSize, apertureRect); |
| 45 layer->setResourceId(1); | 45 layer->setResourceId(1); |
| 46 | 46 |
| 47 // This scale should not affect the generated quad geometry, but only | 47 // This scale should not affect the generated quad geometry, but only |
| 48 // the shared draw transform. | 48 // the shared draw transform. |
| 49 WebKit::WebTransformationMatrix transform; | 49 gfx::Transform transform; |
| 50 transform.scale(10); | 50 transform.PreconcatScale(10, 10); |
| 51 layer->setDrawTransform(transform); | 51 layer->setDrawTransform(transform); |
| 52 | 52 |
| 53 AppendQuadsData data; | 53 AppendQuadsData data; |
| 54 layer->appendQuads(quadCuller, data); | 54 layer->appendQuads(quadCuller, data); |
| 55 | 55 |
| 56 // Verify quad rects | 56 // Verify quad rects |
| 57 const QuadList& quads = quadCuller.quadList(); | 57 const QuadList& quads = quadCuller.quadList(); |
| 58 EXPECT_EQ(quads.size(), 8); | 58 EXPECT_EQ(quads.size(), 8); |
| 59 Region remaining(visibleContentRect); | 59 Region remaining(visibleContentRect); |
| 60 for (size_t i = 0; i < quads.size(); ++i) { | 60 for (size_t i = 0; i < quads.size(); ++i) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 80 texRect.Scale(bitmapSize.width(), bitmapSize.height()); | 80 texRect.Scale(bitmapSize.width(), bitmapSize.height()); |
| 81 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); | 81 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); |
| 82 } | 82 } |
| 83 EXPECT_RECT_EQ(texRemaining.bounds(), apertureRect); | 83 EXPECT_RECT_EQ(texRemaining.bounds(), apertureRect); |
| 84 Region apertureRegion(apertureRect); | 84 Region apertureRegion(apertureRect); |
| 85 EXPECT_EQ(texRemaining, apertureRegion); | 85 EXPECT_EQ(texRemaining, apertureRegion); |
| 86 } | 86 } |
| 87 | 87 |
| 88 } // namespace | 88 } // namespace |
| 89 } // namespace cc | 89 } // namespace cc |
| OLD | NEW |