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

Side by Side Diff: third_party/WebKit/Source/core/frame/ImageBitmapTest.cpp

Issue 2893243003: color: Add ColorCanvasExtensions runtime flag (Closed)
Patch Set: Fix logic error in ImageBitmap Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 // Save the global memory cache to restore it upon teardown. 69 // Save the global memory cache to restore it upon teardown.
70 global_memory_cache_ = ReplaceMemoryCacheForTesting(MemoryCache::Create()); 70 global_memory_cache_ = ReplaceMemoryCacheForTesting(MemoryCache::Create());
71 71
72 // Save the state of experimental canvas features and color correct 72 // Save the state of experimental canvas features and color correct
73 // rendering flags to restore them on teardown. 73 // rendering flags to restore them on teardown.
74 experimental_canvas_features = 74 experimental_canvas_features =
75 RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled(); 75 RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled();
76 color_correct_rendering = 76 color_correct_rendering =
77 RuntimeEnabledFeatures::colorCorrectRenderingEnabled(); 77 RuntimeEnabledFeatures::colorCorrectRenderingEnabled();
78 color_correct_rendering_default_mode = 78 color_canvas_extensions =
79 RuntimeEnabledFeatures::colorCorrectRenderingDefaultModeEnabled(); 79 RuntimeEnabledFeatures::colorCanvasExtensionsEnabled();
80 } 80 }
81 virtual void TearDown() { 81 virtual void TearDown() {
82 // Garbage collection is required prior to switching out the 82 // Garbage collection is required prior to switching out the
83 // test's memory cache; image resources are released, evicting 83 // test's memory cache; image resources are released, evicting
84 // them from the cache. 84 // them from the cache.
85 ThreadState::Current()->CollectGarbage(BlinkGC::kNoHeapPointersOnStack, 85 ThreadState::Current()->CollectGarbage(BlinkGC::kNoHeapPointersOnStack,
86 BlinkGC::kGCWithSweep, 86 BlinkGC::kGCWithSweep,
87 BlinkGC::kForcedGC); 87 BlinkGC::kForcedGC);
88 88
89 ReplaceMemoryCacheForTesting(global_memory_cache_.Release()); 89 ReplaceMemoryCacheForTesting(global_memory_cache_.Release());
90 RuntimeEnabledFeatures::setExperimentalCanvasFeaturesEnabled( 90 RuntimeEnabledFeatures::setExperimentalCanvasFeaturesEnabled(
91 experimental_canvas_features); 91 experimental_canvas_features);
92 RuntimeEnabledFeatures::setColorCorrectRenderingEnabled( 92 RuntimeEnabledFeatures::setColorCorrectRenderingEnabled(
93 color_correct_rendering); 93 color_correct_rendering);
94 RuntimeEnabledFeatures::setColorCorrectRenderingDefaultModeEnabled( 94 RuntimeEnabledFeatures::setColorCanvasExtensionsEnabled(
95 color_correct_rendering_default_mode); 95 color_canvas_extensions);
96 } 96 }
97 97
98 sk_sp<SkImage> image_, image2_; 98 sk_sp<SkImage> image_, image2_;
99 Persistent<MemoryCache> global_memory_cache_; 99 Persistent<MemoryCache> global_memory_cache_;
100 bool experimental_canvas_features; 100 bool experimental_canvas_features;
101 bool color_correct_rendering; 101 bool color_correct_rendering;
102 bool color_correct_rendering_default_mode; 102 bool color_canvas_extensions;
103 }; 103 };
104 104
105 TEST_F(ImageBitmapTest, ImageResourceConsistency) { 105 TEST_F(ImageBitmapTest, ImageResourceConsistency) {
106 const ImageBitmapOptions default_options; 106 const ImageBitmapOptions default_options;
107 HTMLImageElement* image_element = 107 HTMLImageElement* image_element =
108 HTMLImageElement::Create(*Document::Create()); 108 HTMLImageElement::Create(*Document::Create());
109 ImageResourceContent* image = ImageResourceContent::CreateLoaded( 109 ImageResourceContent* image = ImageResourceContent::CreateLoaded(
110 StaticBitmapImage::Create(image_).Get()); 110 StaticBitmapImage::Create(image_).Get());
111 image_element->SetImageForTest(image); 111 image_element->SetImageForTest(image);
112 112
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 static const Vector<String> kConversions = { 210 static const Vector<String> kConversions = {
211 "none", "default", "default", "srgb", "linear-rgb", "p3", "rec2020"}; 211 "none", "default", "default", "srgb", "linear-rgb", "p3", "rec2020"};
212 options.setColorSpaceConversion( 212 options.setColorSpaceConversion(
213 kConversions[static_cast<uint8_t>(color_space_conversion)]); 213 kConversions[static_cast<uint8_t>(color_space_conversion)]);
214 214
215 // Set the runtime flags 215 // Set the runtime flags
216 bool flag = (color_space_conversion != 216 bool flag = (color_space_conversion !=
217 ColorSpaceConversion::DEFAULT_NOT_COLOR_CORRECTED); 217 ColorSpaceConversion::DEFAULT_NOT_COLOR_CORRECTED);
218 RuntimeEnabledFeatures::setExperimentalCanvasFeaturesEnabled(true); 218 RuntimeEnabledFeatures::setExperimentalCanvasFeaturesEnabled(true);
219 RuntimeEnabledFeatures::setColorCorrectRenderingEnabled(flag); 219 RuntimeEnabledFeatures::setColorCorrectRenderingEnabled(flag);
220 RuntimeEnabledFeatures::setColorCorrectRenderingDefaultModeEnabled(!flag); 220 RuntimeEnabledFeatures::setColorCanvasExtensionsEnabled(flag);
221 221
222 return options; 222 return options;
223 } 223 }
224 224
225 TEST_F(ImageBitmapTest, ImageBitmapColorSpaceConversionHTMLImageElement) { 225 TEST_F(ImageBitmapTest, ImageBitmapColorSpaceConversionHTMLImageElement) {
226 HTMLImageElement* image_element = 226 HTMLImageElement* image_element =
227 HTMLImageElement::Create(*Document::Create()); 227 HTMLImageElement::Create(*Document::Create());
228 228
229 SkPaint p; 229 SkPaint p;
230 p.setColor(SK_ColorRED); 230 p.setColor(SK_ColorRED);
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 color_space_xform->apply(color_format, transformed_pixel.get(), 608 color_space_xform->apply(color_format, transformed_pixel.get(),
609 color_format32, src_pixel.get(), 1, 609 color_format32, src_pixel.get(), 1,
610 SkAlphaType::kUnpremul_SkAlphaType); 610 SkAlphaType::kUnpremul_SkAlphaType);
611 int compare = std::memcmp(converted_pixel.get(), transformed_pixel.get(), 611 int compare = std::memcmp(converted_pixel.get(), transformed_pixel.get(),
612 image_info.bytesPerPixel()); 612 image_info.bytesPerPixel());
613 ASSERT_EQ(compare, 0); 613 ASSERT_EQ(compare, 0);
614 } 614 }
615 } 615 }
616 616
617 } // namespace blink 617 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698