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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 483 |
484 int compare = std::memcmp(convertedPixel.get(), transformedPixel.get(), | 484 int compare = std::memcmp(convertedPixel.get(), transformedPixel.get(), |
485 imageInfo.bytesPerPixel()); | 485 imageInfo.bytesPerPixel()); |
486 ASSERT_EQ(compare, 0); | 486 ASSERT_EQ(compare, 0); |
487 } | 487 } |
488 } | 488 } |
489 | 489 |
490 TEST_F(ImageBitmapTest, ImageBitmapColorSpaceConversionImageData) { | 490 TEST_F(ImageBitmapTest, ImageBitmapColorSpaceConversionImageData) { |
491 unsigned char dataBuffer[4] = {255, 0, 0, 255}; | 491 unsigned char dataBuffer[4] = {255, 0, 0, 255}; |
492 DOMUint8ClampedArray* data = DOMUint8ClampedArray::create(dataBuffer, 4); | 492 DOMUint8ClampedArray* data = DOMUint8ClampedArray::create(dataBuffer, 4); |
493 ImageData* imageData = ImageData::create(IntSize(1, 1), data); | 493 ImageData* imageData = |
| 494 ImageData::create(IntSize(1, 1), NotShared<DOMUint8ClampedArray>(data)); |
494 std::unique_ptr<uint8_t[]> srcPixel(new uint8_t[4]()); | 495 std::unique_ptr<uint8_t[]> srcPixel(new uint8_t[4]()); |
495 memcpy(srcPixel.get(), imageData->data()->data(), 4); | 496 memcpy(srcPixel.get(), imageData->data()->data(), 4); |
496 | 497 |
497 Optional<IntRect> cropRect = IntRect(0, 0, 1, 1); | 498 Optional<IntRect> cropRect = IntRect(0, 0, 1, 1); |
498 sk_sp<SkColorSpace> colorSpace = nullptr; | 499 sk_sp<SkColorSpace> colorSpace = nullptr; |
499 SkColorSpaceXform::ColorFormat colorFormat32 = | 500 SkColorSpaceXform::ColorFormat colorFormat32 = |
500 (SkColorType::kN32_SkColorType == kBGRA_8888_SkColorType) | 501 (SkColorType::kN32_SkColorType == kBGRA_8888_SkColorType) |
501 ? SkColorSpaceXform::ColorFormat::kBGRA_8888_ColorFormat | 502 ? SkColorSpaceXform::ColorFormat::kBGRA_8888_ColorFormat |
502 : SkColorSpaceXform::ColorFormat::kRGBA_8888_ColorFormat; | 503 : SkColorSpaceXform::ColorFormat::kRGBA_8888_ColorFormat; |
503 SkColorType colorType = SkColorType::kN32_SkColorType; | 504 SkColorType colorType = SkColorType::kN32_SkColorType; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 colorSpaceXform->apply(colorFormat, transformedPixel.get(), colorFormat32, | 552 colorSpaceXform->apply(colorFormat, transformedPixel.get(), colorFormat32, |
552 srcPixel.get(), 1, | 553 srcPixel.get(), 1, |
553 SkAlphaType::kUnpremul_SkAlphaType); | 554 SkAlphaType::kUnpremul_SkAlphaType); |
554 int compare = std::memcmp(convertedPixel.get(), transformedPixel.get(), | 555 int compare = std::memcmp(convertedPixel.get(), transformedPixel.get(), |
555 imageInfo.bytesPerPixel()); | 556 imageInfo.bytesPerPixel()); |
556 ASSERT_EQ(compare, 0); | 557 ASSERT_EQ(compare, 0); |
557 } | 558 } |
558 } | 559 } |
559 | 560 |
560 } // namespace blink | 561 } // namespace blink |
OLD | NEW |