OLD | NEW |
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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 | 491 |
492 int compare = std::memcmp(converted_pixel.get(), transformed_pixel.get(), | 492 int compare = std::memcmp(converted_pixel.get(), transformed_pixel.get(), |
493 image_info.bytesPerPixel()); | 493 image_info.bytesPerPixel()); |
494 ASSERT_EQ(compare, 0); | 494 ASSERT_EQ(compare, 0); |
495 } | 495 } |
496 } | 496 } |
497 | 497 |
498 TEST_F(ImageBitmapTest, ImageBitmapColorSpaceConversionImageData) { | 498 TEST_F(ImageBitmapTest, ImageBitmapColorSpaceConversionImageData) { |
499 unsigned char data_buffer[4] = {255, 0, 0, 255}; | 499 unsigned char data_buffer[4] = {255, 0, 0, 255}; |
500 DOMUint8ClampedArray* data = DOMUint8ClampedArray::Create(data_buffer, 4); | 500 DOMUint8ClampedArray* data = DOMUint8ClampedArray::Create(data_buffer, 4); |
501 ImageData* image_data = ImageData::Create(IntSize(1, 1), data); | 501 ImageData* image_data = |
| 502 ImageData::Create(IntSize(1, 1), NotShared<DOMUint8ClampedArray>(data)); |
502 std::unique_ptr<uint8_t[]> src_pixel(new uint8_t[4]()); | 503 std::unique_ptr<uint8_t[]> src_pixel(new uint8_t[4]()); |
503 memcpy(src_pixel.get(), image_data->data()->Data(), 4); | 504 memcpy(src_pixel.get(), image_data->data()->Data(), 4); |
504 | 505 |
505 Optional<IntRect> crop_rect = IntRect(0, 0, 1, 1); | 506 Optional<IntRect> crop_rect = IntRect(0, 0, 1, 1); |
506 sk_sp<SkColorSpace> color_space = nullptr; | 507 sk_sp<SkColorSpace> color_space = nullptr; |
507 SkColorSpaceXform::ColorFormat color_format32 = | 508 SkColorSpaceXform::ColorFormat color_format32 = |
508 (SkColorType::kN32_SkColorType == kBGRA_8888_SkColorType) | 509 (SkColorType::kN32_SkColorType == kBGRA_8888_SkColorType) |
509 ? SkColorSpaceXform::ColorFormat::kBGRA_8888_ColorFormat | 510 ? SkColorSpaceXform::ColorFormat::kBGRA_8888_ColorFormat |
510 : SkColorSpaceXform::ColorFormat::kRGBA_8888_ColorFormat; | 511 : SkColorSpaceXform::ColorFormat::kRGBA_8888_ColorFormat; |
511 SkColorType color_type = SkColorType::kN32_SkColorType; | 512 SkColorType color_type = SkColorType::kN32_SkColorType; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 color_space_xform->apply(color_format, transformed_pixel.get(), | 561 color_space_xform->apply(color_format, transformed_pixel.get(), |
561 color_format32, src_pixel.get(), 1, | 562 color_format32, src_pixel.get(), 1, |
562 SkAlphaType::kUnpremul_SkAlphaType); | 563 SkAlphaType::kUnpremul_SkAlphaType); |
563 int compare = std::memcmp(converted_pixel.get(), transformed_pixel.get(), | 564 int compare = std::memcmp(converted_pixel.get(), transformed_pixel.get(), |
564 image_info.bytesPerPixel()); | 565 image_info.bytesPerPixel()); |
565 ASSERT_EQ(compare, 0); | 566 ASSERT_EQ(compare, 0); |
566 } | 567 } |
567 } | 568 } |
568 | 569 |
569 } // namespace blink | 570 } // namespace blink |
OLD | NEW |