| 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/resources/picture_layer_tiling.h" | |
| 6 | |
| 7 #include <limits> | 5 #include <limits> |
| 8 #include <set> | 6 #include <set> |
| 9 | 7 |
| 10 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
| 9 #include "cc/resources/active_picture_layer_tiling.h" |
| 10 #include "cc/resources/picture_layer_tiling.h" |
| 11 #include "cc/resources/picture_layer_tiling_set.h" | 11 #include "cc/resources/picture_layer_tiling_set.h" |
| 12 #include "cc/test/fake_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
| 13 #include "cc/test/fake_output_surface_client.h" | 13 #include "cc/test/fake_output_surface_client.h" |
| 14 #include "cc/test/fake_picture_layer_tiling_client.h" | 14 #include "cc/test/fake_picture_layer_tiling_client.h" |
| 15 #include "cc/test/fake_picture_pile_impl.h" | 15 #include "cc/test/fake_picture_pile_impl.h" |
| 16 #include "cc/test/test_context_provider.h" | 16 #include "cc/test/test_context_provider.h" |
| 17 #include "cc/test/test_shared_bitmap_manager.h" | 17 #include "cc/test/test_shared_bitmap_manager.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "ui/gfx/geometry/quad_f.h" | 19 #include "ui/gfx/geometry/quad_f.h" |
| 20 #include "ui/gfx/geometry/rect_conversions.h" | 20 #include "ui/gfx/geometry/rect_conversions.h" |
| 21 #include "ui/gfx/geometry/size_conversions.h" | 21 #include "ui/gfx/geometry/size_conversions.h" |
| 22 | 22 |
| 23 namespace cc { | 23 namespace cc { |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 static gfx::Rect ViewportInLayerSpace( | 26 static gfx::Rect ViewportInLayerSpace( |
| 27 const gfx::Transform& transform, | 27 const gfx::Transform& transform, |
| 28 const gfx::Size& device_viewport) { | 28 const gfx::Size& device_viewport) { |
| 29 | 29 |
| 30 gfx::Transform inverse; | 30 gfx::Transform inverse; |
| 31 if (!transform.GetInverse(&inverse)) | 31 if (!transform.GetInverse(&inverse)) |
| 32 return gfx::Rect(); | 32 return gfx::Rect(); |
| 33 | 33 |
| 34 gfx::RectF viewport_in_layer_space = MathUtil::ProjectClippedRect( | 34 gfx::RectF viewport_in_layer_space = MathUtil::ProjectClippedRect( |
| 35 inverse, gfx::RectF(gfx::Point(0, 0), device_viewport)); | 35 inverse, gfx::RectF(gfx::Point(0, 0), device_viewport)); |
| 36 return ToEnclosingRect(viewport_in_layer_space); | 36 return ToEnclosingRect(viewport_in_layer_space); |
| 37 } | 37 } |
| 38 | 38 |
| 39 class TestablePictureLayerTiling : public PictureLayerTiling { | 39 class TestablePictureLayerTiling : public ActivePictureLayerTiling { |
| 40 public: | 40 public: |
| 41 using PictureLayerTiling::SetLiveTilesRect; | 41 using PictureLayerTiling::SetLiveTilesRect; |
| 42 using PictureLayerTiling::TileAt; | 42 using PictureLayerTiling::TileAt; |
| 43 | 43 |
| 44 static scoped_ptr<TestablePictureLayerTiling> Create( | 44 static scoped_ptr<TestablePictureLayerTiling> Create( |
| 45 float contents_scale, | 45 float contents_scale, |
| 46 scoped_refptr<RasterSource> raster_source, | 46 scoped_refptr<RasterSource> raster_source, |
| 47 PictureLayerTilingClient* client, | 47 PictureLayerTilingClient* client, |
| 48 const LayerTreeSettings& settings) { | 48 const LayerTreeSettings& settings) { |
| 49 return make_scoped_ptr(new TestablePictureLayerTiling( | 49 return make_scoped_ptr(new TestablePictureLayerTiling( |
| 50 contents_scale, raster_source, client, | 50 contents_scale, raster_source, client, |
| 51 settings.max_tiles_for_interest_area, | 51 settings.max_tiles_for_interest_area, |
| 52 settings.skewport_target_time_in_seconds, | 52 settings.skewport_target_time_in_seconds, |
| 53 settings.skewport_extrapolation_limit_in_content_pixels)); | 53 settings.skewport_extrapolation_limit_in_content_pixels)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 56 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
| 57 | 57 |
| 58 using PictureLayerTiling::ComputeSkewport; | 58 using PictureLayerTiling::ComputeSkewport; |
| 59 using PictureLayerTiling::RemoveTileAt; | 59 using PictureLayerTiling::RemoveTileAt; |
| 60 | 60 |
| 61 protected: | 61 protected: |
| 62 TestablePictureLayerTiling(float contents_scale, | 62 TestablePictureLayerTiling(float contents_scale, |
| 63 scoped_refptr<RasterSource> raster_source, | 63 scoped_refptr<RasterSource> raster_source, |
| 64 PictureLayerTilingClient* client, | 64 PictureLayerTilingClient* client, |
| 65 size_t max_tiles_for_interest_area, | 65 size_t max_tiles_for_interest_area, |
| 66 float skewport_target_time, | 66 float skewport_target_time, |
| 67 int skewport_extrapolation_limit) | 67 int skewport_extrapolation_limit) |
| 68 : PictureLayerTiling(contents_scale, | 68 : ActivePictureLayerTiling(contents_scale, |
| 69 raster_source, | 69 raster_source, |
| 70 client, | 70 client, |
| 71 max_tiles_for_interest_area, | 71 max_tiles_for_interest_area, |
| 72 skewport_target_time, | 72 skewport_target_time, |
| 73 skewport_extrapolation_limit) {} | 73 skewport_extrapolation_limit) {} |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 class PictureLayerTilingIteratorTest : public testing::Test { | 76 class PictureLayerTilingIteratorTest : public testing::Test { |
| 77 public: | 77 public: |
| 78 PictureLayerTilingIteratorTest() {} | 78 PictureLayerTilingIteratorTest() {} |
| 79 ~PictureLayerTilingIteratorTest() override {} | 79 ~PictureLayerTilingIteratorTest() override {} |
| 80 | 80 |
| 81 void Initialize(const gfx::Size& tile_size, | 81 void Initialize(const gfx::Size& tile_size, |
| 82 float contents_scale, | 82 float contents_scale, |
| 83 const gfx::Size& layer_bounds) { | 83 const gfx::Size& layer_bounds) { |
| (...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1976 tiling_->SetRasterSourceAndResize(pile); | 1976 tiling_->SetRasterSourceAndResize(pile); |
| 1977 | 1977 |
| 1978 // Tile size in the tiling should be resized to 250x200. | 1978 // Tile size in the tiling should be resized to 250x200. |
| 1979 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 1979 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 1980 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 1980 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 1981 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); | 1981 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); |
| 1982 } | 1982 } |
| 1983 | 1983 |
| 1984 } // namespace | 1984 } // namespace |
| 1985 } // namespace cc | 1985 } // namespace cc |
| OLD | NEW |