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

Side by Side Diff: cc/paint/discardable_image_map_unittest.cc

Issue 2797583002: cc: Add color space to image decode caches (Closed)
Patch Set: Fix perf test compile Created 3 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/paint/discardable_image_map.h" 5 #include "cc/paint/discardable_image_map.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 25 matching lines...) Expand all
36 }; 36 };
37 37
38 } // namespace 38 } // namespace
39 39
40 class DiscardableImageMapTest : public testing::Test { 40 class DiscardableImageMapTest : public testing::Test {
41 public: 41 public:
42 std::vector<PositionScaleDrawImage> GetDiscardableImagesInRect( 42 std::vector<PositionScaleDrawImage> GetDiscardableImagesInRect(
43 const DiscardableImageMap& image_map, 43 const DiscardableImageMap& image_map,
44 const gfx::Rect& rect) { 44 const gfx::Rect& rect) {
45 std::vector<DrawImage> draw_images; 45 std::vector<DrawImage> draw_images;
46 image_map.GetDiscardableImagesInRect(rect, 1.f, &draw_images); 46 gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateXYZD50();
vmpstr 2017/04/04 01:16:43 Ah yes, the elusive XYZD50 color space. We meet ag
ccameron 2017/04/04 06:41:10 Added a comment about the choice ... it's a "not n
47 image_map.GetDiscardableImagesInRect(rect, 1.f, target_color_space,
48 &draw_images);
47 49
48 std::vector<size_t> indices; 50 std::vector<size_t> indices;
49 image_map.images_rtree_.Search(rect, &indices); 51 image_map.images_rtree_.Search(rect, &indices);
50 std::vector<PositionScaleDrawImage> position_draw_images; 52 std::vector<PositionScaleDrawImage> position_draw_images;
51 for (size_t index : indices) { 53 for (size_t index : indices) {
52 position_draw_images.push_back( 54 position_draw_images.push_back(
53 PositionScaleDrawImage(image_map.all_images_[index].first.image(), 55 PositionScaleDrawImage(image_map.all_images_[index].first.image(),
54 image_map.all_images_[index].second, 56 image_map.all_images_[index].second,
55 image_map.all_images_[index].first.scale())); 57 image_map.all_images_[index].first.scale()));
56 } 58 }
57 59
58 EXPECT_EQ(draw_images.size(), position_draw_images.size()); 60 EXPECT_EQ(draw_images.size(), position_draw_images.size());
59 for (size_t i = 0; i < draw_images.size(); ++i) 61 for (size_t i = 0; i < draw_images.size(); ++i) {
60 EXPECT_TRUE(draw_images[i].image() == position_draw_images[i].image); 62 EXPECT_TRUE(draw_images[i].image() == position_draw_images[i].image);
63 EXPECT_EQ(draw_images[i].target_color_space(), target_color_space);
64 }
61 return position_draw_images; 65 return position_draw_images;
62 } 66 }
63 67
64 // Note that the image rtree outsets the images by 1, see the comment in 68 // Note that the image rtree outsets the images by 1, see the comment in
65 // DiscardableImagesMetadataCanvas::AddImage. 69 // DiscardableImagesMetadataCanvas::AddImage.
66 std::vector<gfx::Rect> InsetImageRects( 70 std::vector<gfx::Rect> InsetImageRects(
67 const std::vector<PositionScaleDrawImage>& images) { 71 const std::vector<PositionScaleDrawImage>& images) {
68 std::vector<gfx::Rect> result; 72 std::vector<gfx::Rect> result;
69 for (auto& image : images) { 73 for (auto& image : images) {
70 result.push_back(image.image_rect); 74 result.push_back(image.image_rect);
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 512 + 6, 500, 500), inset_rects[0]); 641 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 512 + 6, 500, 500), inset_rects[0]);
638 EXPECT_TRUE(images[1].image == discardable_image[2][1]); 642 EXPECT_TRUE(images[1].image == discardable_image[2][1]);
639 EXPECT_EQ(gfx::Rect(512 + 6, 2 * 512 + 6, 500, 500), inset_rects[1]); 643 EXPECT_EQ(gfx::Rect(512 + 6, 2 * 512 + 6, 500, 500), inset_rects[1]);
640 EXPECT_TRUE(images[2].image == discardable_image[2][3]); 644 EXPECT_TRUE(images[2].image == discardable_image[2][3]);
641 EXPECT_EQ(gfx::Rect(3 * 512 + 6, 2 * 512 + 6, 500, 500), inset_rects[2]); 645 EXPECT_EQ(gfx::Rect(3 * 512 + 6, 2 * 512 + 6, 500, 500), inset_rects[2]);
642 EXPECT_TRUE(images[3].image == discardable_image[3][2]); 646 EXPECT_TRUE(images[3].image == discardable_image[3][2]);
643 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 3 * 512 + 6, 500, 500), inset_rects[3]); 647 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 3 * 512 + 6, 500, 500), inset_rects[3]);
644 } 648 }
645 649
646 } // namespace cc 650 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698