OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 return nullptr; | 274 return nullptr; |
275 | 275 |
276 return new ImageData(IntSize(width, height), data.View()); | 276 return new ImageData(IntSize(width, height), data.View()); |
277 } | 277 } |
278 | 278 |
279 ImageData* ImageData::CreateImageData( | 279 ImageData* ImageData::CreateImageData( |
280 unsigned width, | 280 unsigned width, |
281 unsigned height, | 281 unsigned height, |
282 const ImageDataColorSettings& color_settings, | 282 const ImageDataColorSettings& color_settings, |
283 ExceptionState& exception_state) { | 283 ExceptionState& exception_state) { |
284 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() || | 284 if (!RuntimeEnabledFeatures::colorCanvasExtensionsEnabled()) |
285 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) | |
286 return nullptr; | 285 return nullptr; |
287 | 286 |
288 if (!ImageData::ValidateConstructorArguments( | 287 if (!ImageData::ValidateConstructorArguments( |
289 kParamWidth | kParamHeight, nullptr, width, height, nullptr, | 288 kParamWidth | kParamHeight, nullptr, width, height, nullptr, |
290 &color_settings, &exception_state)) | 289 &color_settings, &exception_state)) |
291 return nullptr; | 290 return nullptr; |
292 | 291 |
293 ImageDataStorageFormat storage_format = | 292 ImageDataStorageFormat storage_format = |
294 ImageData::GetImageDataStorageFormat(color_settings.storageFormat()); | 293 ImageData::GetImageDataStorageFormat(color_settings.storageFormat()); |
295 DOMArrayBufferView* buffer_view = AllocateAndValidateDataArray( | 294 DOMArrayBufferView* buffer_view = AllocateAndValidateDataArray( |
296 4 * width * height, storage_format, &exception_state); | 295 4 * width * height, storage_format, &exception_state); |
297 | 296 |
298 if (!buffer_view) | 297 if (!buffer_view) |
299 return nullptr; | 298 return nullptr; |
300 | 299 |
301 return new ImageData(IntSize(width, height), buffer_view, &color_settings); | 300 return new ImageData(IntSize(width, height), buffer_view, &color_settings); |
302 } | 301 } |
303 | 302 |
304 ImageData* ImageData::CreateImageData(ImageDataArray& data, | 303 ImageData* ImageData::CreateImageData(ImageDataArray& data, |
305 unsigned width, | 304 unsigned width, |
306 unsigned height, | 305 unsigned height, |
307 ImageDataColorSettings& color_settings, | 306 ImageDataColorSettings& color_settings, |
308 ExceptionState& exception_state) { | 307 ExceptionState& exception_state) { |
309 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() || | 308 if (!RuntimeEnabledFeatures::colorCanvasExtensionsEnabled()) |
310 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) | |
311 return nullptr; | 309 return nullptr; |
312 | 310 |
313 DOMArrayBufferView* buffer_view = nullptr; | 311 DOMArrayBufferView* buffer_view = nullptr; |
314 | 312 |
315 // When pixels data is provided, we need to override the storage format of | 313 // When pixels data is provided, we need to override the storage format of |
316 // ImageDataColorSettings with the one that matches the data type of the | 314 // ImageDataColorSettings with the one that matches the data type of the |
317 // pixels. | 315 // pixels. |
318 String storage_format_name; | 316 String storage_format_name; |
319 | 317 |
320 if (data.isUint8ClampedArray()) { | 318 if (data.isUint8ClampedArray()) { |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 if (data_u16_) | 587 if (data_u16_) |
590 return data_u16_->BufferBase(); | 588 return data_u16_->BufferBase(); |
591 if (data_f32_) | 589 if (data_f32_) |
592 return data_f32_->BufferBase(); | 590 return data_f32_->BufferBase(); |
593 return nullptr; | 591 return nullptr; |
594 } | 592 } |
595 | 593 |
596 // For ImageData, the color space is only specified by color settings. | 594 // For ImageData, the color space is only specified by color settings. |
597 // It cannot have a SkColorSpace. This doesn't mean anything. Fix this. | 595 // It cannot have a SkColorSpace. This doesn't mean anything. Fix this. |
598 sk_sp<SkColorSpace> ImageData::GetSkColorSpace() { | 596 sk_sp<SkColorSpace> ImageData::GetSkColorSpace() { |
599 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() || | 597 if (!RuntimeEnabledFeatures::colorCanvasExtensionsEnabled()) |
600 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) | |
601 return nullptr; | 598 return nullptr; |
602 | 599 |
603 return SkColorSpace::MakeSRGB(); | 600 return SkColorSpace::MakeSRGB(); |
604 } | 601 } |
605 | 602 |
606 // This function returns the proper SkColorSpace to color correct the pixels | 603 // This function returns the proper SkColorSpace to color correct the pixels |
607 // stored in ImageData before copying to the canvas. For now, it assumes that | 604 // stored in ImageData before copying to the canvas. For now, it assumes that |
608 // both ImageData and canvas use a linear gamma curve. | 605 // both ImageData and canvas use a linear gamma curve. |
609 sk_sp<SkColorSpace> ImageData::GetSkColorSpace( | 606 sk_sp<SkColorSpace> ImageData::GetSkColorSpace( |
610 const CanvasColorSpace& color_space, | 607 const CanvasColorSpace& color_space, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 SECURITY_CHECK(static_cast<unsigned>(size.Width() * size.Height() * 4) <= | 776 SECURITY_CHECK(static_cast<unsigned>(size.Width() * size.Height() * 4) <= |
780 data_f32_->length()); | 777 data_f32_->length()); |
781 break; | 778 break; |
782 | 779 |
783 default: | 780 default: |
784 NOTREACHED(); | 781 NOTREACHED(); |
785 } | 782 } |
786 } | 783 } |
787 | 784 |
788 } // namespace blink | 785 } // namespace blink |
OLD | NEW |