Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Side by Side Diff: cc/resources/picture_pile_unittest.cc

Issue 14874004: cc: Inflate invalidation in each picture list (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for windows Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/resources/picture_pile.h"
6 #include "cc/test/fake_content_layer_client.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/gfx/rect_conversions.h"
9
10 namespace cc {
11 namespace {
12
13 class TestPicturePile : public PicturePile {
14 public:
15 using PicturePile::buffer_pixels;
16
17 PictureListMap& picture_list_map() { return picture_list_map_; }
18
19 typedef PicturePile::PictureList PictureList;
20 typedef PicturePile::PictureListMapKey PictureListMapKey;
21 typedef PicturePile::PictureListMap PictureListMap;
22
23 protected:
24 virtual ~TestPicturePile() {}
25 };
26
27 // Update this if the implementation changes.
28 const int kBasePictureSize = 3000;
29
30 TEST(PicturePileTest, InvalidateOnTileBoundaryInflated) {
31 FakeContentLayerClient client;
32 scoped_refptr<TestPicturePile> pile = new TestPicturePile;
33 SkColor background_color = SK_ColorBLUE;
34
35 float min_scale = 0.125;
36
37 gfx::Size layer_size(kBasePictureSize * 2, kBasePictureSize * 2);
38 pile->Resize(layer_size);
39 pile->SetTileGridSize(gfx::Size(kBasePictureSize, kBasePictureSize));
40 pile->SetMinContentsScale(min_scale);
41
42 // Verify kBasePictureSize matches our expectations. Update kBasePictureSize
43 // if these are wrong.
44 EXPECT_EQ(3, pile->tiling().num_tiles_x());
45 EXPECT_EQ(3, pile->tiling().num_tiles_y());
46 EXPECT_EQ(kBasePictureSize, pile->tiling().max_texture_size().width());
47 EXPECT_EQ(kBasePictureSize, pile->tiling().max_texture_size().height());
48
49 // We should have 1/.125 - 1 = 7 border pixels.
50 EXPECT_EQ(7, pile->buffer_pixels());
51 EXPECT_EQ(7, pile->tiling().border_texels());
52
53 // Update the whole layer.
54 pile->Update(&client,
55 background_color,
56 gfx::Rect(layer_size),
57 gfx::Rect(layer_size),
58 NULL);
59
60 // Invalidate something just over a tile boundary by a single pixel.
61 // This will invalidate the tile (1, 1), as well as 1 row of pixels in (1, 0).
62 gfx::Rect invalidate_rect(
63 pile->tiling().TileBoundsWithBorder(0, 0).right(),
64 pile->tiling().TileBoundsWithBorder(0, 0).bottom() - 1,
65 50,
66 50);
67 pile->Update(&client,
68 background_color,
69 invalidate_rect,
70 gfx::Rect(layer_size),
71 NULL);
72
73 for (int i = 0; i < pile->tiling().num_tiles_x(); ++i) {
74 for (int j = 0; j < pile->tiling().num_tiles_y(); ++j) {
75 // (1, 0) and (1, 1) should be invalidated partially.
76 bool expect_invalidated = i == 1 && (j == 0 || j == 1);
77
78 TestPicturePile::PictureList& picture_list =
79 pile->picture_list_map().find(
80 TestPicturePile::PictureListMapKey(i, j))->second;
81 if (!expect_invalidated) {
82 EXPECT_EQ(1u, picture_list.size()) << "For i,j " << i << "," << j;
83 continue;
84 }
85
86 EXPECT_EQ(2u, picture_list.size()) << "For i,j " << i << "," << j;
87 for (TestPicturePile::PictureList::iterator it = picture_list.begin();
88 it != picture_list.end();
89 ++it) {
90 // The invalidation in each tile should have been made large enough
91 // that scaling it never makes a rect smaller than 1 px wide or tall.
92 scoped_refptr<Picture> picture = *it;
93 gfx::Rect picture_rect = gfx::ToEnclosedRect(
94 gfx::ScaleRect(picture->LayerRect(), min_scale));
95 EXPECT_FALSE(picture_rect.IsEmpty()) << "Picture rect " <<
96 picture_rect.ToString();
97 }
98 }
99 }
100 }
101
102 } // namespace
103 } // namespace cc
OLDNEW
« cc/resources/picture_pile.cc ('K') | « cc/resources/picture_pile_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698