OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layers/tiled_layer.h" | 5 #include "cc/layers/tiled_layer.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 layer->draw_properties().drawable_content_rect = content_rect; | 1704 layer->draw_properties().drawable_content_rect = content_rect; |
1705 | 1705 |
1706 layer->SetTexturePriorities(priority_calculator_); | 1706 layer->SetTexturePriorities(priority_calculator_); |
1707 resource_manager_->PrioritizeTextures(); | 1707 resource_manager_->PrioritizeTextures(); |
1708 layer->SavePaintProperties(); | 1708 layer->SavePaintProperties(); |
1709 | 1709 |
1710 // Update the whole tile. | 1710 // Update the whole tile. |
1711 layer->Update(queue_.get(), nullptr); | 1711 layer->Update(queue_.get(), nullptr); |
1712 layer->tracking_layer_painter()->ResetPaintedRect(); | 1712 layer->tracking_layer_painter()->ResetPaintedRect(); |
1713 | 1713 |
1714 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); | 1714 EXPECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); |
1715 UpdateTextures(); | 1715 UpdateTextures(); |
1716 | 1716 |
1717 // Invalidate the entire layer in content space. When painting, the rect given | 1717 // Invalidate the entire layer in content space. When painting, the rect given |
1718 // to webkit should match the layer's bounds. | 1718 // to webkit should match the layer's bounds. |
1719 layer->InvalidateContentRect(content_rect); | 1719 layer->InvalidateContentRect(content_rect); |
1720 layer->Update(queue_.get(), nullptr); | 1720 layer->Update(queue_.get(), nullptr); |
1721 | 1721 |
1722 // Rounding leads to an extra pixel. | 1722 // Rounding leads to an extra pixel. |
1723 gfx::Rect expanded_layer_rect(layer_rect); | 1723 gfx::Rect expanded_layer_rect(layer_rect); |
1724 expanded_layer_rect.set_height(32); | 1724 expanded_layer_rect.set_height(32); |
1725 EXPECT_RECT_EQ(expanded_layer_rect, | 1725 EXPECT_EQ(expanded_layer_rect, |
1726 layer->tracking_layer_painter()->PaintedRect()); | 1726 layer->tracking_layer_painter()->PaintedRect()); |
1727 } | 1727 } |
1728 | 1728 |
1729 TEST_F(TiledLayerTest, | 1729 TEST_F(TiledLayerTest, |
1730 NonIntegerContentsScaleIsNotDistortedDuringInvalidation) { | 1730 NonIntegerContentsScaleIsNotDistortedDuringInvalidation) { |
1731 scoped_refptr<UpdateTrackingTiledLayer> layer = | 1731 scoped_refptr<UpdateTrackingTiledLayer> layer = |
1732 make_scoped_refptr(new UpdateTrackingTiledLayer(resource_manager_.get())); | 1732 make_scoped_refptr(new UpdateTrackingTiledLayer(resource_manager_.get())); |
1733 | 1733 |
1734 layer_tree_host_->root_layer()->AddChild(layer); | 1734 layer_tree_host_->root_layer()->AddChild(layer); |
1735 | 1735 |
1736 gfx::Rect layer_rect(0, 0, 30, 31); | 1736 gfx::Rect layer_rect(0, 0, 30, 31); |
1737 layer->SetPosition(layer_rect.origin()); | 1737 layer->SetPosition(layer_rect.origin()); |
1738 layer->SetBounds(layer_rect.size()); | 1738 layer->SetBounds(layer_rect.size()); |
1739 layer->UpdateContentsScale(1.3f); | 1739 layer->UpdateContentsScale(1.3f); |
1740 | 1740 |
1741 gfx::Rect content_rect(layer->content_bounds()); | 1741 gfx::Rect content_rect(layer->content_bounds()); |
1742 layer->draw_properties().visible_content_rect = content_rect; | 1742 layer->draw_properties().visible_content_rect = content_rect; |
1743 layer->draw_properties().drawable_content_rect = content_rect; | 1743 layer->draw_properties().drawable_content_rect = content_rect; |
1744 | 1744 |
1745 layer->SetTexturePriorities(priority_calculator_); | 1745 layer->SetTexturePriorities(priority_calculator_); |
1746 resource_manager_->PrioritizeTextures(); | 1746 resource_manager_->PrioritizeTextures(); |
1747 layer->SavePaintProperties(); | 1747 layer->SavePaintProperties(); |
1748 | 1748 |
1749 // Update the whole tile. | 1749 // Update the whole tile. |
1750 layer->Update(queue_.get(), nullptr); | 1750 layer->Update(queue_.get(), nullptr); |
1751 layer->tracking_layer_painter()->ResetPaintedRect(); | 1751 layer->tracking_layer_painter()->ResetPaintedRect(); |
1752 | 1752 |
1753 EXPECT_RECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); | 1753 EXPECT_EQ(gfx::Rect(), layer->tracking_layer_painter()->PaintedRect()); |
1754 UpdateTextures(); | 1754 UpdateTextures(); |
1755 | 1755 |
1756 // Invalidate the entire layer in layer space. When painting, the rect given | 1756 // Invalidate the entire layer in layer space. When painting, the rect given |
1757 // to webkit should match the layer's bounds. | 1757 // to webkit should match the layer's bounds. |
1758 layer->SetNeedsDisplayRect(layer_rect); | 1758 layer->SetNeedsDisplayRect(layer_rect); |
1759 layer->Update(queue_.get(), nullptr); | 1759 layer->Update(queue_.get(), nullptr); |
1760 | 1760 |
1761 // Rounding leads to an extra pixel. | 1761 // Rounding leads to an extra pixel. |
1762 gfx::Rect expanded_layer_rect(layer_rect); | 1762 gfx::Rect expanded_layer_rect(layer_rect); |
1763 expanded_layer_rect.set_height(32); | 1763 expanded_layer_rect.set_height(32); |
1764 EXPECT_RECT_EQ(expanded_layer_rect, | 1764 EXPECT_EQ(expanded_layer_rect, |
1765 layer->tracking_layer_painter()->PaintedRect()); | 1765 layer->tracking_layer_painter()->PaintedRect()); |
1766 } | 1766 } |
1767 | 1767 |
1768 } // namespace | 1768 } // namespace |
1769 } // namespace cc | 1769 } // namespace cc |
OLD | NEW |