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

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

Issue 2797583002: cc: Add color space to image decode caches (Closed)
Patch Set: Remove dead code 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
« no previous file with comments | « cc/paint/discardable_image_map.cc ('k') | cc/paint/display_item_list.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Choose a not-SRGB-and-not-invalid target color space to verify that it
47 // is passed correctly to the resulting DrawImages.
48 gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateXYZD50();
49 image_map.GetDiscardableImagesInRect(rect, 1.f, target_color_space,
50 &draw_images);
47 51
48 std::vector<size_t> indices; 52 std::vector<size_t> indices;
49 image_map.images_rtree_.Search(rect, &indices); 53 image_map.images_rtree_.Search(rect, &indices);
50 std::vector<PositionScaleDrawImage> position_draw_images; 54 std::vector<PositionScaleDrawImage> position_draw_images;
51 for (size_t index : indices) { 55 for (size_t index : indices) {
52 position_draw_images.push_back( 56 position_draw_images.push_back(
53 PositionScaleDrawImage(image_map.all_images_[index].first.image(), 57 PositionScaleDrawImage(image_map.all_images_[index].first.image(),
54 image_map.all_images_[index].second, 58 image_map.all_images_[index].second,
55 image_map.all_images_[index].first.scale())); 59 image_map.all_images_[index].first.scale()));
56 } 60 }
57 61
58 EXPECT_EQ(draw_images.size(), position_draw_images.size()); 62 EXPECT_EQ(draw_images.size(), position_draw_images.size());
59 for (size_t i = 0; i < draw_images.size(); ++i) 63 for (size_t i = 0; i < draw_images.size(); ++i) {
60 EXPECT_TRUE(draw_images[i].image() == position_draw_images[i].image); 64 EXPECT_TRUE(draw_images[i].image() == position_draw_images[i].image);
65 EXPECT_EQ(draw_images[i].target_color_space(), target_color_space);
66 }
61 return position_draw_images; 67 return position_draw_images;
62 } 68 }
63 69
64 // Note that the image rtree outsets the images by 1, see the comment in 70 // Note that the image rtree outsets the images by 1, see the comment in
65 // DiscardableImagesMetadataCanvas::AddImage. 71 // DiscardableImagesMetadataCanvas::AddImage.
66 std::vector<gfx::Rect> InsetImageRects( 72 std::vector<gfx::Rect> InsetImageRects(
67 const std::vector<PositionScaleDrawImage>& images) { 73 const std::vector<PositionScaleDrawImage>& images) {
68 std::vector<gfx::Rect> result; 74 std::vector<gfx::Rect> result;
69 for (auto& image : images) { 75 for (auto& image : images) {
70 result.push_back(image.image_rect); 76 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]); 643 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 512 + 6, 500, 500), inset_rects[0]);
638 EXPECT_TRUE(images[1].image == discardable_image[2][1]); 644 EXPECT_TRUE(images[1].image == discardable_image[2][1]);
639 EXPECT_EQ(gfx::Rect(512 + 6, 2 * 512 + 6, 500, 500), inset_rects[1]); 645 EXPECT_EQ(gfx::Rect(512 + 6, 2 * 512 + 6, 500, 500), inset_rects[1]);
640 EXPECT_TRUE(images[2].image == discardable_image[2][3]); 646 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]); 647 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]); 648 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]); 649 EXPECT_EQ(gfx::Rect(2 * 512 + 6, 3 * 512 + 6, 500, 500), inset_rects[3]);
644 } 650 }
645 651
646 } // namespace cc 652 } // namespace cc
OLDNEW
« no previous file with comments | « cc/paint/discardable_image_map.cc ('k') | cc/paint/display_item_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698