| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 return nullptr; | 270 return nullptr; |
| 271 | 271 |
| 272 return new ImageData(IntSize(width, height), data); | 272 return new ImageData(IntSize(width, height), data); |
| 273 } | 273 } |
| 274 | 274 |
| 275 ImageData* ImageData::createImageData( | 275 ImageData* ImageData::createImageData( |
| 276 unsigned width, | 276 unsigned width, |
| 277 unsigned height, | 277 unsigned height, |
| 278 const ImageDataColorSettings& colorSettings, | 278 const ImageDataColorSettings& colorSettings, |
| 279 ExceptionState& exceptionState) { | 279 ExceptionState& exceptionState) { |
| 280 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() || |
| 281 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) |
| 282 return nullptr; |
| 283 |
| 280 if (!ImageData::validateConstructorArguments(kParamWidth | kParamHeight, | 284 if (!ImageData::validateConstructorArguments(kParamWidth | kParamHeight, |
| 281 nullptr, width, height, nullptr, | 285 nullptr, width, height, nullptr, |
| 282 &colorSettings, &exceptionState)) | 286 &colorSettings, &exceptionState)) |
| 283 return nullptr; | 287 return nullptr; |
| 284 | 288 |
| 285 ImageDataStorageFormat storageFormat = | 289 ImageDataStorageFormat storageFormat = |
| 286 ImageData::imageDataStorageFormat(colorSettings.storageFormat()); | 290 ImageData::imageDataStorageFormat(colorSettings.storageFormat()); |
| 287 DOMArrayBufferView* bufferView = allocateAndValidateDataArray( | 291 DOMArrayBufferView* bufferView = allocateAndValidateDataArray( |
| 288 4 * width * height, storageFormat, &exceptionState); | 292 4 * width * height, storageFormat, &exceptionState); |
| 289 | 293 |
| 290 if (!bufferView) | 294 if (!bufferView) |
| 291 return nullptr; | 295 return nullptr; |
| 292 | 296 |
| 293 return new ImageData(IntSize(width, height), bufferView, &colorSettings); | 297 return new ImageData(IntSize(width, height), bufferView, &colorSettings); |
| 294 } | 298 } |
| 295 | 299 |
| 296 ImageData* ImageData::createImageData(ImageDataArray& data, | 300 ImageData* ImageData::createImageData(ImageDataArray& data, |
| 297 unsigned width, | 301 unsigned width, |
| 298 unsigned height, | 302 unsigned height, |
| 299 ImageDataColorSettings& colorSettings, | 303 ImageDataColorSettings& colorSettings, |
| 300 ExceptionState& exceptionState) { | 304 ExceptionState& exceptionState) { |
| 305 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() || |
| 306 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) |
| 307 return nullptr; |
| 308 |
| 301 DOMArrayBufferView* bufferView = nullptr; | 309 DOMArrayBufferView* bufferView = nullptr; |
| 302 // When pixels data is provided, we need to override the storage format of | 310 // When pixels data is provided, we need to override the storage format of |
| 303 // ImageDataColorSettings with the one that matches the data type of the | 311 // ImageDataColorSettings with the one that matches the data type of the |
| 304 // pixels. | 312 // pixels. |
| 305 String storageFormatName; | 313 String storageFormatName; |
| 306 | 314 |
| 307 if (data.isUint8ClampedArray()) { | 315 if (data.isUint8ClampedArray()) { |
| 308 bufferView = data.getAsUint8ClampedArray(); | 316 bufferView = data.getAsUint8ClampedArray(); |
| 309 storageFormatName = kUint8ClampedArrayStorageFormatName; | 317 storageFormatName = kUint8ClampedArrayStorageFormatName; |
| 310 } else if (data.isUint16Array()) { | 318 } else if (data.isUint16Array()) { |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 SECURITY_CHECK(static_cast<unsigned>(size.width() * size.height() * 4) <= | 762 SECURITY_CHECK(static_cast<unsigned>(size.width() * size.height() * 4) <= |
| 755 m_dataF32->length()); | 763 m_dataF32->length()); |
| 756 break; | 764 break; |
| 757 | 765 |
| 758 default: | 766 default: |
| 759 NOTREACHED(); | 767 NOTREACHED(); |
| 760 } | 768 } |
| 761 } | 769 } |
| 762 | 770 |
| 763 } // namespace blink | 771 } // namespace blink |
| OLD | NEW |