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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 return nullptr; | 273 return nullptr; |
274 | 274 |
275 return new ImageData(IntSize(width, height), data); | 275 return new ImageData(IntSize(width, height), data); |
276 } | 276 } |
277 | 277 |
278 ImageData* ImageData::createImageData( | 278 ImageData* ImageData::createImageData( |
279 unsigned width, | 279 unsigned width, |
280 unsigned height, | 280 unsigned height, |
281 const ImageDataColorSettings& color_settings, | 281 const ImageDataColorSettings& color_settings, |
282 ExceptionState& exception_state) { | 282 ExceptionState& exception_state) { |
| 283 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() || |
| 284 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) |
| 285 return nullptr; |
| 286 |
283 if (!ImageData::ValidateConstructorArguments( | 287 if (!ImageData::ValidateConstructorArguments( |
284 kParamWidth | kParamHeight, nullptr, width, height, nullptr, | 288 kParamWidth | kParamHeight, nullptr, width, height, nullptr, |
285 &color_settings, &exception_state)) | 289 &color_settings, &exception_state)) |
286 return nullptr; | 290 return nullptr; |
287 | 291 |
288 ImageDataStorageFormat storage_format = | 292 ImageDataStorageFormat storage_format = |
289 ImageData::GetImageDataStorageFormat(color_settings.storageFormat()); | 293 ImageData::GetImageDataStorageFormat(color_settings.storageFormat()); |
290 DOMArrayBufferView* buffer_view = AllocateAndValidateDataArray( | 294 DOMArrayBufferView* buffer_view = AllocateAndValidateDataArray( |
291 4 * width * height, storage_format, &exception_state); | 295 4 * width * height, storage_format, &exception_state); |
292 | 296 |
293 if (!buffer_view) | 297 if (!buffer_view) |
294 return nullptr; | 298 return nullptr; |
295 | 299 |
296 return new ImageData(IntSize(width, height), buffer_view, &color_settings); | 300 return new ImageData(IntSize(width, height), buffer_view, &color_settings); |
297 } | 301 } |
298 | 302 |
299 ImageData* ImageData::createImageData(ImageDataArray& data, | 303 ImageData* ImageData::createImageData(ImageDataArray& data, |
300 unsigned width, | 304 unsigned width, |
301 unsigned height, | 305 unsigned height, |
302 ImageDataColorSettings& color_settings, | 306 ImageDataColorSettings& color_settings, |
303 ExceptionState& exception_state) { | 307 ExceptionState& exception_state) { |
| 308 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() || |
| 309 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) |
| 310 return nullptr; |
| 311 |
304 DOMArrayBufferView* buffer_view = nullptr; | 312 DOMArrayBufferView* buffer_view = nullptr; |
| 313 |
305 // When pixels data is provided, we need to override the storage format of | 314 // When pixels data is provided, we need to override the storage format of |
306 // ImageDataColorSettings with the one that matches the data type of the | 315 // ImageDataColorSettings with the one that matches the data type of the |
307 // pixels. | 316 // pixels. |
308 String storage_format_name; | 317 String storage_format_name; |
309 | 318 |
310 if (data.isUint8ClampedArray()) { | 319 if (data.isUint8ClampedArray()) { |
311 buffer_view = data.getAsUint8ClampedArray(); | 320 buffer_view = data.getAsUint8ClampedArray(); |
312 storage_format_name = kUint8ClampedArrayStorageFormatName; | 321 storage_format_name = kUint8ClampedArrayStorageFormatName; |
313 } else if (data.isUint16Array()) { | 322 } else if (data.isUint16Array()) { |
314 buffer_view = data.getAsUint16Array(); | 323 buffer_view = data.getAsUint16Array(); |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 SECURITY_CHECK(static_cast<unsigned>(size.Width() * size.Height() * 4) <= | 768 SECURITY_CHECK(static_cast<unsigned>(size.Width() * size.Height() * 4) <= |
760 data_f32_->length()); | 769 data_f32_->length()); |
761 break; | 770 break; |
762 | 771 |
763 default: | 772 default: |
764 NOTREACHED(); | 773 NOTREACHED(); |
765 } | 774 } |
766 } | 775 } |
767 | 776 |
768 } // namespace blink | 777 } // namespace blink |
OLD | NEW |