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

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

Issue 2575693005: Add unit test for color managed ImageBitamp(ImageBitmap) constructor (Closed)
Patch Set: Breaking the CL into multiple ones - ImageBitmap(ImageBitmap) unit test Created 4 years 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/frame/ImageBitmap.h" 31 #include "core/frame/ImageBitmap.h"
32 32
33 #include "SkPixelRef.h" // FIXME: qualify this skia header file. 33 #include "SkPixelRef.h" // FIXME: qualify this skia header file.
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/fetch/MemoryCache.h" 35 #include "core/fetch/MemoryCache.h"
36 #include "core/frame/FrameView.h"
36 #include "core/html/HTMLCanvasElement.h" 37 #include "core/html/HTMLCanvasElement.h"
37 #include "core/html/HTMLImageElement.h" 38 #include "core/html/HTMLImageElement.h"
38 #include "core/html/HTMLVideoElement.h" 39 #include "core/html/HTMLVideoElement.h"
39 #include "core/loader/resource/ImageResourceContent.h" 40 #include "core/loader/resource/ImageResourceContent.h"
40 #include "platform/graphics/StaticBitmapImage.h" 41 #include "platform/graphics/StaticBitmapImage.h"
41 #include "platform/graphics/skia/SkiaUtils.h" 42 #include "platform/graphics/skia/SkiaUtils.h"
42 #include "platform/heap/Handle.h" 43 #include "platform/heap/Handle.h"
43 #include "platform/image-decoders/ImageDecoder.h" 44 #include "platform/image-decoders/ImageDecoder.h"
44 #include "platform/network/ResourceRequest.h" 45 #include "platform/network/ResourceRequest.h"
45 #include "testing/gtest/include/gtest/gtest.h" 46 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 12 matching lines...) Expand all
58 m_image = surface->makeImageSnapshot(); 59 m_image = surface->makeImageSnapshot();
59 60
60 sk_sp<SkSurface> surface2 = SkSurface::MakeRasterN32Premul(5, 5); 61 sk_sp<SkSurface> surface2 = SkSurface::MakeRasterN32Premul(5, 5);
61 surface2->getCanvas()->clear(0xAAAAAAAA); 62 surface2->getCanvas()->clear(0xAAAAAAAA);
62 m_image2 = surface2->makeImageSnapshot(); 63 m_image2 = surface2->makeImageSnapshot();
63 64
64 // Save the global memory cache to restore it upon teardown. 65 // Save the global memory cache to restore it upon teardown.
65 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create()); 66 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create());
66 67
67 // Save the state of experimental canvas features and color correct 68 // Save the state of experimental canvas features and color correct
68 // rendering flags to restore them on teardown. 69 // rendering flags to restore them on teardown. Each test that changes the
70 // flags must restore them to prevent affecting other ImageBitmap tests.
71 // This is an extra safety precaution to prevent such an error to leak from
72 // this test suite.
69 experimentalCanvasFeatures = 73 experimentalCanvasFeatures =
70 RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled(); 74 RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled();
71 colorCorrectRendering = 75 colorCorrectRendering =
72 RuntimeEnabledFeatures::colorCorrectRenderingEnabled(); 76 RuntimeEnabledFeatures::colorCorrectRenderingEnabled();
73 colorCorrectRenderingDefaultMode = 77 colorCorrectRenderingDefaultMode =
74 RuntimeEnabledFeatures::colorCorrectRenderingDefaultModeEnabled(); 78 RuntimeEnabledFeatures::colorCorrectRenderingDefaultModeEnabled();
75 } 79 }
76 virtual void TearDown() { 80 virtual void TearDown() {
77 // Garbage collection is required prior to switching out the 81 // Garbage collection is required prior to switching out the
78 // test's memory cache; image resources are released, evicting 82 // test's memory cache; image resources are released, evicting
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 enum class ColorSpaceConversion : uint8_t { 211 enum class ColorSpaceConversion : uint8_t {
208 NONE = 0, 212 NONE = 0,
209 DEFAULT_NOT_COLOR_CORRECTED = 1, 213 DEFAULT_NOT_COLOR_CORRECTED = 1,
210 DEFAULT_COLOR_CORRECTED = 2, 214 DEFAULT_COLOR_CORRECTED = 2,
211 SRGB = 3, 215 SRGB = 3,
212 LINEAR_RGB = 4, 216 LINEAR_RGB = 4,
213 217
214 LAST = LINEAR_RGB 218 LAST = LINEAR_RGB
215 }; 219 };
216 220
217 static ImageBitmap* createImageBitmapWithColorSpaceConversion( 221 struct ColorRenderingRuntimeFlagsStatus {
218 HTMLImageElement* image, 222 bool experimentalCanvasFeatures = false;
219 Optional<IntRect>& cropRect, 223 bool colorCorrectRendering = false;
220 Document* document, 224 bool colorCorrectRenderingDefaultMode = false;
225 };
226
227 static void ReadRuntimeFlags(ColorRenderingRuntimeFlagsStatus& flagsStatus) {
228 flagsStatus.experimentalCanvasFeatures =
229 RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled();
230 flagsStatus.colorCorrectRendering =
231 RuntimeEnabledFeatures::colorCorrectRenderingEnabled();
232 flagsStatus.colorCorrectRenderingDefaultMode =
233 RuntimeEnabledFeatures::colorCorrectRenderingDefaultModeEnabled();
234 }
235
236 static void ResetRuntimeFlags(
237 const ColorRenderingRuntimeFlagsStatus& flagsStatus) {
238 RuntimeEnabledFeatures::setExperimentalCanvasFeaturesEnabled(
239 flagsStatus.experimentalCanvasFeatures);
240 RuntimeEnabledFeatures::setColorCorrectRenderingEnabled(
241 flagsStatus.colorCorrectRendering);
242 RuntimeEnabledFeatures::setColorCorrectRenderingDefaultModeEnabled(
243 flagsStatus.colorCorrectRenderingDefaultMode);
244 }
245
246 static ImageBitmapOptions prepareBitmapOptionsAndSetRuntimeFlags(
221 const ColorSpaceConversion& colorSpaceConversion) { 247 const ColorSpaceConversion& colorSpaceConversion) {
222 // Set the color space conversion in ImageBitmapOptions 248 // Set the color space conversion in ImageBitmapOptions
223 ImageBitmapOptions options; 249 ImageBitmapOptions options;
224 static const Vector<String> conversions = {"none", "default", "default", 250 static const Vector<String> conversions = {"none", "default", "default",
225 "srgb", "linear-rgb"}; 251 "srgb", "linear-rgb"};
226 options.setColorSpaceConversion( 252 options.setColorSpaceConversion(
227 conversions[static_cast<uint8_t>(colorSpaceConversion)]); 253 conversions[static_cast<uint8_t>(colorSpaceConversion)]);
228 254
229 // Set the runtime flags 255 // Set the runtime flags
230 bool flag = (colorSpaceConversion != 256 bool flag = (colorSpaceConversion !=
231 ColorSpaceConversion::DEFAULT_NOT_COLOR_CORRECTED); 257 ColorSpaceConversion::DEFAULT_NOT_COLOR_CORRECTED);
232 RuntimeEnabledFeatures::setExperimentalCanvasFeaturesEnabled(true); 258 RuntimeEnabledFeatures::setExperimentalCanvasFeaturesEnabled(true);
233 RuntimeEnabledFeatures::setColorCorrectRenderingEnabled(flag); 259 RuntimeEnabledFeatures::setColorCorrectRenderingEnabled(flag);
234 RuntimeEnabledFeatures::setColorCorrectRenderingDefaultModeEnabled(!flag); 260 RuntimeEnabledFeatures::setColorCorrectRenderingDefaultModeEnabled(!flag);
235 261
236 // Create and return the ImageBitmap 262 return options;
237 return ImageBitmap::create(image, cropRect, &(image->document()), options);
238 } 263 }
239 264
240 TEST_F(ImageBitmapTest, ImageBitmapColorSpaceConversion) { 265 TEST_F(ImageBitmapTest, ImageBitmapColorSpaceConversionHTMLImageElement) {
266 ColorRenderingRuntimeFlagsStatus flagsStatus;
267 ReadRuntimeFlags(flagsStatus);
dcheng 2016/12/19 18:36:43 Shouldn't the helpers in SetUp/TearDown already ma
zakerinasab1 2016/12/19 19:41:59 As I know it is possible for multiple tests to end
dcheng 2016/12/19 19:47:17 SetUp() and TearDown() are called for each test: h
268
241 HTMLImageElement* imageElement = 269 HTMLImageElement* imageElement =
242 HTMLImageElement::create(*Document::create()); 270 HTMLImageElement::create(*Document::create());
243 271
244 SkPaint p; 272 SkPaint p;
245 p.setColor(SK_ColorRED); 273 p.setColor(SK_ColorRED);
246 sk_sp<SkColorSpace> srcRGBColorSpace = 274 sk_sp<SkColorSpace> srcRGBColorSpace =
247 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); 275 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
248 276
249 SkImageInfo rasterImageInfo = 277 SkImageInfo rasterImageInfo =
250 SkImageInfo::MakeN32Premul(100, 100, srcRGBColorSpace); 278 SkImageInfo::MakeN32Premul(10, 10, srcRGBColorSpace);
251 sk_sp<SkSurface> surface(SkSurface::MakeRaster(rasterImageInfo)); 279 sk_sp<SkSurface> surface(SkSurface::MakeRaster(rasterImageInfo));
252 surface->getCanvas()->drawCircle(50, 50, 50, p); 280 surface->getCanvas()->drawCircle(5, 5, 5, p);
253 sk_sp<SkImage> image = surface->makeImageSnapshot(); 281 sk_sp<SkImage> image = surface->makeImageSnapshot();
254 282
255 std::unique_ptr<uint8_t[]> srcPixel( 283 std::unique_ptr<uint8_t[]> srcPixel(
256 new uint8_t[rasterImageInfo.bytesPerPixel()]()); 284 new uint8_t[rasterImageInfo.bytesPerPixel()]());
257 image->readPixels(rasterImageInfo.makeWH(1, 1), srcPixel.get(), 285 image->readPixels(rasterImageInfo.makeWH(1, 1), srcPixel.get(),
258 image->width() * rasterImageInfo.bytesPerPixel(), 50, 50); 286 image->width() * rasterImageInfo.bytesPerPixel(), 5, 5);
259 287
260 ImageResourceContent* originalImageResource = 288 ImageResourceContent* originalImageResource =
261 ImageResourceContent::create(StaticBitmapImage::create(image).get()); 289 ImageResourceContent::create(StaticBitmapImage::create(image).get());
262 imageElement->setImageResource(originalImageResource); 290 imageElement->setImageResource(originalImageResource);
263 291
264 Optional<IntRect> cropRect = IntRect(0, 0, image->width(), image->height()); 292 Optional<IntRect> cropRect = IntRect(0, 0, image->width(), image->height());
265 293
266 // Create and test the ImageBitmap objects. 294 // Create and test the ImageBitmap objects.
267 // We don't check "none" color space conversion as it requires the encoded 295 // We don't check "none" color space conversion as it requires the encoded
268 // data in a format readable by ImageDecoder. Furthermore, the code path for 296 // data in a format readable by ImageDecoder. Furthermore, the code path for
269 // "none" color space conversion is not affected by this CL. 297 // "none" color space conversion is not affected by this CL.
270 298
271 sk_sp<SkColorSpace> colorSpace = nullptr; 299 sk_sp<SkColorSpace> colorSpace = nullptr;
272 SkColorType colorType = SkColorType::kN32_SkColorType; 300 SkColorType colorType = SkColorType::kN32_SkColorType;
273 SkColorSpaceXform::ColorFormat colorFormat32 = 301 SkColorSpaceXform::ColorFormat colorFormat32 =
274 (colorType == kBGRA_8888_SkColorType) 302 (colorType == kBGRA_8888_SkColorType)
275 ? SkColorSpaceXform::ColorFormat::kBGRA_8888_ColorFormat 303 ? SkColorSpaceXform::ColorFormat::kBGRA_8888_ColorFormat
276 : SkColorSpaceXform::ColorFormat::kRGBA_8888_ColorFormat; 304 : SkColorSpaceXform::ColorFormat::kRGBA_8888_ColorFormat;
277 SkColorSpaceXform::ColorFormat colorFormat = colorFormat32; 305 SkColorSpaceXform::ColorFormat colorFormat = colorFormat32;
278 306
279 for (uint8_t i = static_cast<uint8_t>( 307 for (uint8_t i = static_cast<uint8_t>(
280 ColorSpaceConversion::DEFAULT_NOT_COLOR_CORRECTED); 308 ColorSpaceConversion::DEFAULT_NOT_COLOR_CORRECTED);
281 i <= static_cast<uint8_t>(ColorSpaceConversion::LAST); i++) { 309 i <= static_cast<uint8_t>(ColorSpaceConversion::LAST); i++) {
282 ColorSpaceConversion colorSpaceConversion = 310 ColorSpaceConversion colorSpaceConversion =
283 static_cast<ColorSpaceConversion>(i); 311 static_cast<ColorSpaceConversion>(i);
284 ImageBitmap* imageBitmap = createImageBitmapWithColorSpaceConversion( 312 ImageBitmapOptions options =
285 imageElement, cropRect, &(imageElement->document()), 313 prepareBitmapOptionsAndSetRuntimeFlags(colorSpaceConversion);
286 colorSpaceConversion); 314 ImageBitmap* imageBitmap = ImageBitmap::create(
315 imageElement, cropRect, &(imageElement->document()), options);
316
317 // ColorBehavior::ignore() is used instead of
318 // ColorBehavior::transformToTargetForTesting() to avoid color conversion to
319 // display color profile, as we want to solely rely on the color correction
320 // that happens in ImageBitmap create method.
287 SkImage* convertedImage = 321 SkImage* convertedImage =
288 imageBitmap->bitmapImage() 322 imageBitmap->bitmapImage()
289 ->imageForCurrentFrame(ColorBehavior::ignore()) 323 ->imageForCurrentFrame(ColorBehavior::ignore())
324 .get();
325
326 switch (colorSpaceConversion) {
327 case ColorSpaceConversion::NONE:
328 NOTREACHED();
329 break;
330 case ColorSpaceConversion::DEFAULT_NOT_COLOR_CORRECTED:
331 // TODO(zakerinasab): Replace sRGB with a call to
332 // ImageDecoder::globalTargetColorSpace() when the crash problem on Mac
333 // is fixed. crbug.com/668546.
334 colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
335 colorFormat = colorFormat32;
336 break;
337 case ColorSpaceConversion::DEFAULT_COLOR_CORRECTED:
338 case ColorSpaceConversion::SRGB:
339 colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
340 colorFormat = colorFormat32;
341 break;
342 case ColorSpaceConversion::LINEAR_RGB:
343 colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named);
344 colorType = SkColorType::kRGBA_F16_SkColorType;
345 colorFormat = SkColorSpaceXform::ColorFormat::kRGBA_F16_ColorFormat;
346 break;
347 default:
348 NOTREACHED();
349 }
350
351 SkImageInfo imageInfo = SkImageInfo::Make(
352 1, 1, colorType, SkAlphaType::kPremul_SkAlphaType, colorSpace);
353 std::unique_ptr<uint8_t[]> convertedPixel(
354 new uint8_t[imageInfo.bytesPerPixel()]());
355 convertedImage->readPixels(
356 imageInfo, convertedPixel.get(),
357 convertedImage->width() * imageInfo.bytesPerPixel(), 5, 5);
358
359 // Transform the source pixel and check if the image bitmap color conversion
360 // is done correctly.
361 std::unique_ptr<SkColorSpaceXform> colorSpaceXform =
362 SkColorSpaceXform::New(srcRGBColorSpace.get(), colorSpace.get());
363 std::unique_ptr<uint8_t[]> transformedPixel(
364 new uint8_t[imageInfo.bytesPerPixel()]());
365 colorSpaceXform->apply(colorFormat, transformedPixel.get(), colorFormat32,
366 srcPixel.get(), 1, SkAlphaType::kPremul_SkAlphaType);
367
368 int compare = std::memcmp(convertedPixel.get(), transformedPixel.get(),
369 imageInfo.bytesPerPixel());
370 ASSERT_EQ(compare, 0);
371 }
372 ResetRuntimeFlags(flagsStatus);
373 }
374
375 TEST_F(ImageBitmapTest, ImageBitmapColorSpaceConversionImageBitmap) {
376 ColorRenderingRuntimeFlagsStatus flagsStatus;
377 ReadRuntimeFlags(flagsStatus);
378
379 HTMLImageElement* imageElement =
380 HTMLImageElement::create(*Document::create());
381
382 SkPaint p;
383 p.setColor(SK_ColorRED);
384 sk_sp<SkColorSpace> srcRGBColorSpace =
385 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
386
387 SkImageInfo rasterImageInfo =
388 SkImageInfo::MakeN32Premul(10, 10, srcRGBColorSpace);
389 sk_sp<SkSurface> surface(SkSurface::MakeRaster(rasterImageInfo));
390 surface->getCanvas()->drawCircle(5, 5, 5, p);
391 sk_sp<SkImage> image = surface->makeImageSnapshot();
392
393 std::unique_ptr<uint8_t[]> srcPixel(
394 new uint8_t[rasterImageInfo.bytesPerPixel()]());
395 image->readPixels(rasterImageInfo.makeWH(1, 1), srcPixel.get(),
396 image->width() * rasterImageInfo.bytesPerPixel(), 5, 5);
397
398 ImageResourceContent* sourceImageResource =
399 ImageResourceContent::create(StaticBitmapImage::create(image).get());
400 imageElement->setImageResource(sourceImageResource);
401
402 Optional<IntRect> cropRect = IntRect(0, 0, image->width(), image->height());
403 ImageBitmapOptions options =
404 prepareBitmapOptionsAndSetRuntimeFlags(ColorSpaceConversion::SRGB);
405 ImageBitmap* sourceImageBitmap = ImageBitmap::create(
406 imageElement, cropRect, &(imageElement->document()), options);
407
408 sk_sp<SkColorSpace> colorSpace = nullptr;
409 SkColorType colorType = SkColorType::kN32_SkColorType;
410 SkColorSpaceXform::ColorFormat colorFormat32 =
411 (colorType == kBGRA_8888_SkColorType)
412 ? SkColorSpaceXform::ColorFormat::kBGRA_8888_ColorFormat
413 : SkColorSpaceXform::ColorFormat::kRGBA_8888_ColorFormat;
414 SkColorSpaceXform::ColorFormat colorFormat = colorFormat32;
415
416 for (uint8_t i = static_cast<uint8_t>(
417 ColorSpaceConversion::DEFAULT_NOT_COLOR_CORRECTED);
418 i <= static_cast<uint8_t>(ColorSpaceConversion::LAST); i++) {
419 ColorSpaceConversion colorSpaceConversion =
420 static_cast<ColorSpaceConversion>(i);
421 options = prepareBitmapOptionsAndSetRuntimeFlags(colorSpaceConversion);
422 ImageBitmap* imageBitmap =
423 ImageBitmap::create(sourceImageBitmap, cropRect, options);
424 // ColorBehavior::ignore() is used instead of
425 // ColorBehavior::transformToTargetForTesting() to avoid color conversion to
426 // display color profile, as we want to solely rely on the color correction
427 // that happens in ImageBitmap create method.
428 SkImage* convertedImage =
429 imageBitmap->bitmapImage()
430 ->imageForCurrentFrame(ColorBehavior::ignore())
290 .get(); 431 .get();
291 432
292 switch (colorSpaceConversion) { 433 switch (colorSpaceConversion) {
293 case ColorSpaceConversion::NONE: 434 case ColorSpaceConversion::NONE:
294 NOTREACHED(); 435 NOTREACHED();
295 break; 436 break;
296 case ColorSpaceConversion::DEFAULT_NOT_COLOR_CORRECTED: 437 case ColorSpaceConversion::DEFAULT_NOT_COLOR_CORRECTED:
297 // TODO(zakerinasab): Replace sRGB with a call to 438 // TODO(zakerinasab): Replace sRGB with a call to
298 // ImageDecoder::globalTargetColorSpace() when the crash problem on Mac 439 // ImageDecoder::globalTargetColorSpace() when the crash problem on Mac
299 // is fixed. crbug.com/668546. 440 // is fixed. crbug.com/668546.
(...skipping 13 matching lines...) Expand all
313 default: 454 default:
314 NOTREACHED(); 455 NOTREACHED();
315 } 456 }
316 457
317 SkImageInfo imageInfo = SkImageInfo::Make( 458 SkImageInfo imageInfo = SkImageInfo::Make(
318 1, 1, colorType, SkAlphaType::kPremul_SkAlphaType, colorSpace); 459 1, 1, colorType, SkAlphaType::kPremul_SkAlphaType, colorSpace);
319 std::unique_ptr<uint8_t[]> convertedPixel( 460 std::unique_ptr<uint8_t[]> convertedPixel(
320 new uint8_t[imageInfo.bytesPerPixel()]()); 461 new uint8_t[imageInfo.bytesPerPixel()]());
321 convertedImage->readPixels( 462 convertedImage->readPixels(
322 imageInfo, convertedPixel.get(), 463 imageInfo, convertedPixel.get(),
323 convertedImage->width() * imageInfo.bytesPerPixel(), 50, 50); 464 convertedImage->width() * imageInfo.bytesPerPixel(), 5, 5);
324 465
325 // Transform the source pixel and check if the image bitmap color conversion 466 // Transform the source pixel and check if the image bitmap color conversion
326 // is done correctly. 467 // is done correctly.
327 std::unique_ptr<SkColorSpaceXform> colorSpaceXform = 468 std::unique_ptr<SkColorSpaceXform> colorSpaceXform =
328 SkColorSpaceXform::New(srcRGBColorSpace.get(), colorSpace.get()); 469 SkColorSpaceXform::New(srcRGBColorSpace.get(), colorSpace.get());
329 std::unique_ptr<uint8_t[]> transformedPixel( 470 std::unique_ptr<uint8_t[]> transformedPixel(
330 new uint8_t[imageInfo.bytesPerPixel()]()); 471 new uint8_t[imageInfo.bytesPerPixel()]());
331 colorSpaceXform->apply(colorFormat, transformedPixel.get(), colorFormat32, 472 colorSpaceXform->apply(colorFormat, transformedPixel.get(), colorFormat32,
332 srcPixel.get(), 1, SkAlphaType::kPremul_SkAlphaType); 473 srcPixel.get(), 1, SkAlphaType::kPremul_SkAlphaType);
333 474
334 int compare = std::memcmp(convertedPixel.get(), transformedPixel.get(), 475 int compare = std::memcmp(convertedPixel.get(), transformedPixel.get(),
335 imageInfo.bytesPerPixel()); 476 imageInfo.bytesPerPixel());
336 ASSERT_EQ(compare, 0); 477 ASSERT_EQ(compare, 0);
337 } 478 }
479 ResetRuntimeFlags(flagsStatus);
338 } 480 }
339 481
340 } // namespace blink 482 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698