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

Side by Side Diff: cc/raster/raster_source_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/raster/raster_source.cc ('k') | cc/tiles/checker_image_tracker_unittest.cc » ('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 2013 The Chromium Authors. All rights reserved. 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 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/raster/raster_source.h" 5 #include "cc/raster/raster_source.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 recording_source->add_draw_image(discardable_image[1][1], 208 recording_source->add_draw_image(discardable_image[1][1],
209 gfx::Point(260, 260)); 209 gfx::Point(260, 260));
210 recording_source->SetGenerateDiscardableImagesMetadata(true); 210 recording_source->SetGenerateDiscardableImagesMetadata(true);
211 recording_source->Rerecord(); 211 recording_source->Rerecord();
212 212
213 scoped_refptr<RasterSource> raster = 213 scoped_refptr<RasterSource> raster =
214 RasterSource::CreateFromRecordingSource(recording_source.get(), false); 214 RasterSource::CreateFromRecordingSource(recording_source.get(), false);
215 215
216 // Tile sized iterators. These should find only one pixel ref. 216 // Tile sized iterators. These should find only one pixel ref.
217 { 217 {
218 gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateSRGB();
218 std::vector<DrawImage> images; 219 std::vector<DrawImage> images;
219 raster->GetDiscardableImagesInRect(gfx::Rect(0, 0, 256, 256), 1.f, &images); 220 raster->GetDiscardableImagesInRect(gfx::Rect(0, 0, 256, 256), 1.f,
221 target_color_space, &images);
220 EXPECT_EQ(1u, images.size()); 222 EXPECT_EQ(1u, images.size());
221 EXPECT_EQ(discardable_image[0][0], images[0].image()); 223 EXPECT_EQ(discardable_image[0][0], images[0].image());
224 EXPECT_EQ(target_color_space, images[0].target_color_space());
222 } 225 }
223 // Shifted tile sized iterators. These should find only one pixel ref. 226 // Shifted tile sized iterators. These should find only one pixel ref.
224 { 227 {
228 gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateXYZD50();
225 std::vector<DrawImage> images; 229 std::vector<DrawImage> images;
226 raster->GetDiscardableImagesInRect(gfx::Rect(260, 260, 256, 256), 1.f, 230 raster->GetDiscardableImagesInRect(gfx::Rect(260, 260, 256, 256), 1.f,
227 &images); 231 target_color_space, &images);
228 EXPECT_EQ(1u, images.size()); 232 EXPECT_EQ(1u, images.size());
229 EXPECT_EQ(discardable_image[1][1], images[0].image()); 233 EXPECT_EQ(discardable_image[1][1], images[0].image());
234 EXPECT_EQ(target_color_space, images[0].target_color_space());
230 } 235 }
231 // Ensure there's no discardable pixel refs in the empty cell 236 // Ensure there's no discardable pixel refs in the empty cell
232 { 237 {
238 gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateSRGB();
233 std::vector<DrawImage> images; 239 std::vector<DrawImage> images;
234 raster->GetDiscardableImagesInRect(gfx::Rect(0, 256, 256, 256), 1.f, 240 raster->GetDiscardableImagesInRect(gfx::Rect(0, 256, 256, 256), 1.f,
235 &images); 241 target_color_space, &images);
236 EXPECT_EQ(0u, images.size()); 242 EXPECT_EQ(0u, images.size());
237 } 243 }
238 // Layer sized iterators. These should find three pixel ref. 244 // Layer sized iterators. These should find three pixel ref.
239 { 245 {
246 gfx::ColorSpace target_color_space;
240 std::vector<DrawImage> images; 247 std::vector<DrawImage> images;
241 raster->GetDiscardableImagesInRect(gfx::Rect(0, 0, 512, 512), 1.f, &images); 248 raster->GetDiscardableImagesInRect(gfx::Rect(0, 0, 512, 512), 1.f,
249 target_color_space, &images);
242 EXPECT_EQ(3u, images.size()); 250 EXPECT_EQ(3u, images.size());
243 EXPECT_EQ(discardable_image[0][0], images[0].image()); 251 EXPECT_EQ(discardable_image[0][0], images[0].image());
244 EXPECT_EQ(discardable_image[0][1], images[1].image()); 252 EXPECT_EQ(discardable_image[0][1], images[1].image());
245 EXPECT_EQ(discardable_image[1][1], images[2].image()); 253 EXPECT_EQ(discardable_image[1][1], images[2].image());
254 EXPECT_EQ(target_color_space, images[0].target_color_space());
255 EXPECT_EQ(target_color_space, images[1].target_color_space());
256 EXPECT_EQ(target_color_space, images[2].target_color_space());
246 } 257 }
247 } 258 }
248 259
249 TEST(RasterSourceTest, RasterFullContents) { 260 TEST(RasterSourceTest, RasterFullContents) {
250 gfx::Size layer_bounds(3, 5); 261 gfx::Size layer_bounds(3, 5);
251 float contents_scale = 1.5f; 262 float contents_scale = 1.5f;
252 float raster_divisions = 2.f; 263 float raster_divisions = 2.f;
253 264
254 std::unique_ptr<FakeRecordingSource> recording_source = 265 std::unique_ptr<FakeRecordingSource> recording_source =
255 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); 266 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds);
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 24)); 621 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 24));
611 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 24)); 622 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 24));
612 for (int x = 0; x < 49; ++x) 623 for (int x = 0; x < 49; ++x)
613 EXPECT_EQ(SK_ColorRED, bitmap.getColor(x, 12)); 624 EXPECT_EQ(SK_ColorRED, bitmap.getColor(x, 12));
614 for (int y = 0; y < 24; ++y) 625 for (int y = 0; y < 24; ++y)
615 EXPECT_EQ(SK_ColorRED, bitmap.getColor(24, y)); 626 EXPECT_EQ(SK_ColorRED, bitmap.getColor(24, y));
616 } 627 }
617 628
618 } // namespace 629 } // namespace
619 } // namespace cc 630 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/raster_source.cc ('k') | cc/tiles/checker_image_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698