Chromium Code Reviews| 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/tiled_layer_impl.h" | 7 #include "cc/tiled_layer_impl.h" |
| 8 | 8 |
| 9 #include "cc/append_quads_data.h" | 9 #include "cc/append_quads_data.h" |
| 10 #include "cc/layer_tiling_data.h" | 10 #include "cc/layer_tiling_data.h" |
| 11 #include "cc/single_thread_proxy.h" | 11 #include "cc/single_thread_proxy.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/tile_draw_quad.h" | 14 #include "cc/tile_draw_quad.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 "third_party/khronos/GLES2/gl2.h" | |
| 18 #include <public/WebTransformationMatrix.h> | |
| 17 | 19 |
| 18 using namespace cc; | 20 using namespace cc; |
| 19 using namespace LayerTestCommon; | 21 using namespace LayerTestCommon; |
| 22 using namespace WebKit; | |
|
jamesr
2012/11/09 18:40:09
using statements aren't style guide compliant (nei
Sami
2012/11/11 16:56:27
Done.
| |
| 20 | 23 |
| 21 namespace { | 24 namespace { |
| 22 | 25 |
| 23 // Create a default tiled layer with textures for all tiles and a default | 26 // Create a default tiled layer with textures for all tiles and a default |
| 24 // visibility of the entire layer size. | 27 // visibility of the entire layer size. |
| 25 static scoped_ptr<TiledLayerImpl> createLayer(const gfx::Size& tileSize, const g fx::Size& layerSize, LayerTilingData::BorderTexelOption borderTexels) | 28 static scoped_ptr<TiledLayerImpl> createLayer(const gfx::Size& tileSize, const g fx::Size& layerSize, LayerTilingData::BorderTexelOption borderTexels) |
| 26 { | 29 { |
| 27 scoped_ptr<TiledLayerImpl> layer = TiledLayerImpl::create(1); | 30 scoped_ptr<TiledLayerImpl> layer = TiledLayerImpl::create(1); |
| 28 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(tileSize, border Texels); | 31 scoped_ptr<LayerTilingData> tiler = LayerTilingData::create(tileSize, border Texels); |
| 29 tiler->setBounds(layerSize); | 32 tiler->setBounds(layerSize); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 MockQuadCuller quadCuller; | 130 MockQuadCuller quadCuller; |
| 128 AppendQuadsData data; | 131 AppendQuadsData data; |
| 129 layer->appendQuads(quadCuller, data); | 132 layer->appendQuads(quadCuller, data); |
| 130 EXPECT_TRUE(data.hadMissingTiles); | 133 EXPECT_TRUE(data.hadMissingTiles); |
| 131 EXPECT_EQ(quadCuller.quadList().size(), 4u); | 134 EXPECT_EQ(quadCuller.quadList().size(), 4u); |
| 132 for (size_t i = 0; i < quadCuller.quadList().size(); ++i) | 135 for (size_t i = 0; i < quadCuller.quadList().size(); ++i) |
| 133 EXPECT_NE(quadCuller.quadList()[i]->material(), DrawQuad::TiledConte nt); | 136 EXPECT_NE(quadCuller.quadList()[i]->material(), DrawQuad::TiledConte nt); |
| 134 } | 137 } |
| 135 } | 138 } |
| 136 | 139 |
| 137 static void getQuads(QuadList& quads, SharedQuadStateList& sharedStates, gfx::Si ze tileSize, const gfx::Size& layerSize, LayerTilingData::BorderTexelOption bord erTexelOption, const gfx::Rect& visibleContentRect) | 140 static void getQuads(QuadList& quads, SharedQuadStateList& sharedStates, gfx::Si ze tileSize, const gfx::Size& layerSize, LayerTilingData::BorderTexelOption bord erTexelOption, const gfx::Rect& visibleContentRect, const WebTransformationMatri x drawTransform = WebTransformationMatrix()) |
| 138 { | 141 { |
| 139 scoped_ptr<TiledLayerImpl> layer = createLayer(tileSize, layerSize, borderTe xelOption); | 142 scoped_ptr<TiledLayerImpl> layer = createLayer(tileSize, layerSize, borderTe xelOption); |
| 140 layer->setVisibleContentRect(visibleContentRect); | 143 layer->setVisibleContentRect(visibleContentRect); |
| 141 layer->setBounds(layerSize); | 144 layer->setBounds(layerSize); |
| 145 layer->setDrawTransform(drawTransform); | |
| 142 | 146 |
| 143 MockQuadCuller quadCuller(quads, sharedStates); | 147 MockQuadCuller quadCuller(quads, sharedStates); |
| 144 AppendQuadsData data; | 148 AppendQuadsData data; |
| 145 layer->appendQuads(quadCuller, data); | 149 layer->appendQuads(quadCuller, data); |
| 146 } | 150 } |
| 147 | 151 |
| 148 // Test with both border texels and without. | 152 // Test with both border texels and without. |
| 149 #define WITH_AND_WITHOUT_BORDER_TEST(testFixtureName) \ | 153 #define WITH_AND_WITHOUT_BORDER_TEST(testFixtureName) \ |
| 150 TEST(TiledLayerImplTest, testFixtureName##NoBorders) \ | 154 TEST(TiledLayerImplTest, testFixtureName##NoBorders) \ |
| 151 { \ | 155 { \ |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 getQuads(quads, sharedStates, tileSize, layerSize, LayerTilingData::NoBorder Texels, gfx::Rect(gfx::Point(), layerSize)); | 224 getQuads(quads, sharedStates, tileSize, layerSize, LayerTilingData::NoBorder Texels, gfx::Rect(gfx::Point(), layerSize)); |
| 221 | 225 |
| 222 for (size_t i = 0; i < quads.size(); ++i) { | 226 for (size_t i = 0; i < quads.size(); ++i) { |
| 223 ASSERT_EQ(quads[i]->material(), DrawQuad::TiledContent) << quadString << i; | 227 ASSERT_EQ(quads[i]->material(), DrawQuad::TiledContent) << quadString << i; |
| 224 TileDrawQuad* quad = static_cast<TileDrawQuad*>(quads[i]); | 228 TileDrawQuad* quad = static_cast<TileDrawQuad*>(quads[i]); |
| 225 | 229 |
| 226 EXPECT_EQ(gfx::Rect(0, 0, 1, 1), quad->opaqueRect()) << quadString << i; | 230 EXPECT_EQ(gfx::Rect(0, 0, 1, 1), quad->opaqueRect()) << quadString << i; |
| 227 } | 231 } |
| 228 } | 232 } |
| 229 | 233 |
| 234 TEST(TiledLayerImplTest, nearestFilteringForTranslatedQuads) | |
| 235 { | |
| 236 gfx::Size tileSize(50, 50); | |
| 237 gfx::Size layerSize(250, 250); | |
| 238 QuadList quads; | |
| 239 SharedQuadStateList sharedStates; | |
| 240 getQuads(quads, sharedStates, tileSize, layerSize, LayerTilingData::HasBorde rTexels, gfx::Rect(gfx::Point(), layerSize)); | |
| 241 | |
| 242 for (size_t i = 0; i < quads.size(); ++i) { | |
| 243 ASSERT_EQ(quads[i]->material(), DrawQuad::TiledContent) << quadString << i; | |
| 244 TileDrawQuad* quad = static_cast<TileDrawQuad*>(quads[i]); | |
| 245 | |
| 246 EXPECT_EQ(GL_NEAREST, quad->textureFilter()) << quadString << i; | |
| 247 } | |
| 248 } | |
| 249 | |
| 250 TEST(TiledLayerImplTest, linearFilteringForScaledQuads) | |
| 251 { | |
| 252 gfx::Size tileSize(50, 50); | |
| 253 gfx::Size layerSize(250, 250); | |
| 254 QuadList quads; | |
| 255 SharedQuadStateList sharedStates; | |
| 256 WebTransformationMatrix drawTransform; | |
| 257 | |
| 258 drawTransform.scale(2); | |
| 259 getQuads(quads, sharedStates, tileSize, layerSize, LayerTilingData::HasBorde rTexels, gfx::Rect(gfx::Point(), layerSize), drawTransform); | |
| 260 | |
| 261 for (size_t i = 0; i < quads.size(); ++i) { | |
| 262 ASSERT_EQ(quads[i]->material(), DrawQuad::TiledContent) << quadString << i; | |
| 263 TileDrawQuad* quad = static_cast<TileDrawQuad*>(quads[i]); | |
| 264 | |
| 265 EXPECT_EQ(GL_LINEAR, quad->textureFilter()) << quadString << i; | |
| 266 } | |
| 267 } | |
| 268 | |
| 269 TEST(TiledLayerImplTest, linearFilteringForTransformedQuads) | |
| 270 { | |
| 271 gfx::Size tileSize(50, 50); | |
| 272 gfx::Size layerSize(250, 250); | |
| 273 QuadList quads; | |
| 274 SharedQuadStateList sharedStates; | |
| 275 WebTransformationMatrix drawTransform; | |
| 276 | |
| 277 drawTransform.rotate3d(15, 30, 45); | |
| 278 getQuads(quads, sharedStates, tileSize, layerSize, LayerTilingData::HasBorde rTexels, gfx::Rect(gfx::Point(), layerSize), drawTransform); | |
| 279 | |
| 280 for (size_t i = 0; i < quads.size(); ++i) { | |
| 281 ASSERT_EQ(quads[i]->material(), DrawQuad::TiledContent) << quadString << i; | |
| 282 TileDrawQuad* quad = static_cast<TileDrawQuad*>(quads[i]); | |
| 283 | |
| 284 EXPECT_EQ(GL_LINEAR, quad->textureFilter()) << quadString << i; | |
| 285 } | |
| 286 } | |
| 287 | |
| 230 } // anonymous namespace | 288 } // anonymous namespace |
| OLD | NEW |