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

Side by Side Diff: cc/raster/raster_source_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 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 recording_source->add_draw_image(discardable_image[1][1], 207 recording_source->add_draw_image(discardable_image[1][1],
208 gfx::Point(260, 260)); 208 gfx::Point(260, 260));
209 recording_source->SetGenerateDiscardableImagesMetadata(true); 209 recording_source->SetGenerateDiscardableImagesMetadata(true);
210 recording_source->Rerecord(); 210 recording_source->Rerecord();
211 211
212 scoped_refptr<RasterSource> raster = 212 scoped_refptr<RasterSource> raster =
213 RasterSource::CreateFromRecordingSource(recording_source.get(), false); 213 RasterSource::CreateFromRecordingSource(recording_source.get(), false);
214 214
215 // Tile sized iterators. These should find only one pixel ref. 215 // Tile sized iterators. These should find only one pixel ref.
216 { 216 {
217 gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateSRGB();
217 std::vector<DrawImage> images; 218 std::vector<DrawImage> images;
218 raster->GetDiscardableImagesInRect(gfx::Rect(0, 0, 256, 256), 1.f, &images); 219 raster->GetDiscardableImagesInRect(gfx::Rect(0, 0, 256, 256), 1.f,
220 target_color_space, &images);
219 EXPECT_EQ(1u, images.size()); 221 EXPECT_EQ(1u, images.size());
220 EXPECT_EQ(discardable_image[0][0], images[0].image()); 222 EXPECT_EQ(discardable_image[0][0], images[0].image());
223 EXPECT_EQ(target_color_space, images[0].target_color_space());
221 } 224 }
222 // Shifted tile sized iterators. These should find only one pixel ref. 225 // Shifted tile sized iterators. These should find only one pixel ref.
223 { 226 {
227 gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateXYZD50();
224 std::vector<DrawImage> images; 228 std::vector<DrawImage> images;
225 raster->GetDiscardableImagesInRect(gfx::Rect(260, 260, 256, 256), 1.f, 229 raster->GetDiscardableImagesInRect(gfx::Rect(260, 260, 256, 256), 1.f,
226 &images); 230 target_color_space, &images);
227 EXPECT_EQ(1u, images.size()); 231 EXPECT_EQ(1u, images.size());
228 EXPECT_EQ(discardable_image[1][1], images[0].image()); 232 EXPECT_EQ(discardable_image[1][1], images[0].image());
233 EXPECT_EQ(target_color_space, images[0].target_color_space());
229 } 234 }
230 // Ensure there's no discardable pixel refs in the empty cell 235 // Ensure there's no discardable pixel refs in the empty cell
231 { 236 {
237 gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateSRGB();
232 std::vector<DrawImage> images; 238 std::vector<DrawImage> images;
233 raster->GetDiscardableImagesInRect(gfx::Rect(0, 256, 256, 256), 1.f, 239 raster->GetDiscardableImagesInRect(gfx::Rect(0, 256, 256, 256), 1.f,
234 &images); 240 target_color_space, &images);
235 EXPECT_EQ(0u, images.size()); 241 EXPECT_EQ(0u, images.size());
236 } 242 }
237 // Layer sized iterators. These should find three pixel ref. 243 // Layer sized iterators. These should find three pixel ref.
238 { 244 {
245 gfx::ColorSpace target_color_space;
239 std::vector<DrawImage> images; 246 std::vector<DrawImage> images;
240 raster->GetDiscardableImagesInRect(gfx::Rect(0, 0, 512, 512), 1.f, &images); 247 raster->GetDiscardableImagesInRect(gfx::Rect(0, 0, 512, 512), 1.f,
248 target_color_space, &images);
241 EXPECT_EQ(3u, images.size()); 249 EXPECT_EQ(3u, images.size());
242 EXPECT_EQ(discardable_image[0][0], images[0].image()); 250 EXPECT_EQ(discardable_image[0][0], images[0].image());
243 EXPECT_EQ(discardable_image[0][1], images[1].image()); 251 EXPECT_EQ(discardable_image[0][1], images[1].image());
244 EXPECT_EQ(discardable_image[1][1], images[2].image()); 252 EXPECT_EQ(discardable_image[1][1], images[2].image());
253 EXPECT_EQ(target_color_space, images[0].target_color_space());
254 EXPECT_EQ(target_color_space, images[1].target_color_space());
255 EXPECT_EQ(target_color_space, images[2].target_color_space());
245 } 256 }
246 } 257 }
247 258
248 TEST(RasterSourceTest, RasterFullContents) { 259 TEST(RasterSourceTest, RasterFullContents) {
249 gfx::Size layer_bounds(3, 5); 260 gfx::Size layer_bounds(3, 5);
250 float contents_scale = 1.5f; 261 float contents_scale = 1.5f;
251 float raster_divisions = 2.f; 262 float raster_divisions = 2.f;
252 263
253 std::unique_ptr<FakeRecordingSource> recording_source = 264 std::unique_ptr<FakeRecordingSource> recording_source =
254 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds); 265 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 24)); 614 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(0, 24));
604 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 24)); 615 EXPECT_EQ(SK_ColorGREEN, bitmap.getColor(49, 24));
605 for (int x = 0; x < 49; ++x) 616 for (int x = 0; x < 49; ++x)
606 EXPECT_EQ(SK_ColorRED, bitmap.getColor(x, 12)); 617 EXPECT_EQ(SK_ColorRED, bitmap.getColor(x, 12));
607 for (int y = 0; y < 24; ++y) 618 for (int y = 0; y < 24; ++y)
608 EXPECT_EQ(SK_ColorRED, bitmap.getColor(24, y)); 619 EXPECT_EQ(SK_ColorRED, bitmap.getColor(24, y));
609 } 620 }
610 621
611 } // namespace 622 } // namespace
612 } // namespace cc 623 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698