| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 DOMUint8ClampedArray* byteArray = | 199 DOMUint8ClampedArray* byteArray = |
| 200 DOMUint8ClampedArray::createOrNull(dataSize.ValueOrDie()); | 200 DOMUint8ClampedArray::createOrNull(dataSize.ValueOrDie()); |
| 201 if (!byteArray) | 201 if (!byteArray) |
| 202 return nullptr; | 202 return nullptr; |
| 203 | 203 |
| 204 return new ImageData(size, byteArray); | 204 return new ImageData(size, byteArray); |
| 205 } | 205 } |
| 206 | 206 |
| 207 ImageData* ImageData::create(const IntSize& size, | 207 ImageData* ImageData::create(const IntSize& size, |
| 208 DOMUint8ClampedArray* byteArray) { | 208 const NotShared<DOMUint8ClampedArray>& byteArray) { |
| 209 if (!ImageData::validateConstructorArguments(kParamSize | kParamData, &size, | 209 if (!ImageData::validateConstructorArguments(kParamSize | kParamData, &size, |
| 210 0, 0, byteArray)) | 210 0, 0, byteArray.view())) |
| 211 return nullptr; | 211 return nullptr; |
| 212 | 212 |
| 213 return new ImageData(size, byteArray); | 213 return new ImageData(size, byteArray.view()); |
| 214 } | 214 } |
| 215 | 215 |
| 216 ImageData* ImageData::create(unsigned width, | 216 ImageData* ImageData::create(unsigned width, |
| 217 unsigned height, | 217 unsigned height, |
| 218 ExceptionState& exceptionState) { | 218 ExceptionState& exceptionState) { |
| 219 if (!ImageData::validateConstructorArguments(kParamWidth | kParamHeight, | 219 if (!ImageData::validateConstructorArguments(kParamWidth | kParamHeight, |
| 220 nullptr, width, height, nullptr, | 220 nullptr, width, height, nullptr, |
| 221 &exceptionState)) | 221 &exceptionState)) |
| 222 return nullptr; | 222 return nullptr; |
| 223 | 223 |
| 224 DOMArrayBufferView* byteArray = allocateAndValidateDataArray( | 224 DOMArrayBufferView* byteArray = allocateAndValidateDataArray( |
| 225 4 * width * height, kUint8ClampedArrayStorageFormat, &exceptionState); | 225 4 * width * height, kUint8ClampedArrayStorageFormat, &exceptionState); |
| 226 return byteArray ? new ImageData(IntSize(width, height), byteArray) : nullptr; | 226 return byteArray ? new ImageData(IntSize(width, height), byteArray) : nullptr; |
| 227 } | 227 } |
| 228 | 228 |
| 229 ImageData* ImageData::create(DOMUint8ClampedArray* data, | 229 ImageData* ImageData::create(const NotShared<DOMUint8ClampedArray>& data, |
| 230 unsigned width, | 230 unsigned width, |
| 231 ExceptionState& exceptionState) { | 231 ExceptionState& exceptionState) { |
| 232 if (!ImageData::validateConstructorArguments( | 232 if (!ImageData::validateConstructorArguments(kParamData | kParamWidth, |
| 233 kParamData | kParamWidth, nullptr, width, 0, data, &exceptionState)) | 233 nullptr, width, 0, data.view(), |
| 234 &exceptionState)) |
| 234 return nullptr; | 235 return nullptr; |
| 235 | 236 |
| 236 unsigned height = data->length() / (width * 4); | 237 unsigned height = data.view()->length() / (width * 4); |
| 237 return new ImageData(IntSize(width, height), data); | 238 return new ImageData(IntSize(width, height), data.view()); |
| 238 } | 239 } |
| 239 | 240 |
| 240 ImageData* ImageData::create(DOMUint8ClampedArray* data, | 241 ImageData* ImageData::create(const NotShared<DOMUint8ClampedArray>& data, |
| 241 unsigned width, | 242 unsigned width, |
| 242 unsigned height, | 243 unsigned height, |
| 243 ExceptionState& exceptionState) { | 244 ExceptionState& exceptionState) { |
| 244 if (!ImageData::validateConstructorArguments( | 245 if (!ImageData::validateConstructorArguments( |
| 245 kParamData | kParamWidth | kParamHeight, nullptr, width, height, data, | 246 kParamData | kParamWidth | kParamHeight, nullptr, width, height, |
| 246 &exceptionState)) | 247 data.view(), &exceptionState)) |
| 247 return nullptr; | 248 return nullptr; |
| 248 | 249 |
| 249 return new ImageData(IntSize(width, height), data); | 250 return new ImageData(IntSize(width, height), data.view()); |
| 250 } | 251 } |
| 251 | 252 |
| 252 ImageData* ImageData::createImageData( | 253 ImageData* ImageData::createImageData( |
| 253 unsigned width, | 254 unsigned width, |
| 254 unsigned height, | 255 unsigned height, |
| 255 const ImageDataColorSettings& colorSettings, | 256 const ImageDataColorSettings& colorSettings, |
| 256 ExceptionState& exceptionState) { | 257 ExceptionState& exceptionState) { |
| 257 if (!ImageData::validateConstructorArguments(kParamWidth | kParamHeight, | 258 if (!ImageData::validateConstructorArguments(kParamWidth | kParamHeight, |
| 258 nullptr, width, height, nullptr, | 259 nullptr, width, height, nullptr, |
| 259 &exceptionState)) | 260 &exceptionState)) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 271 } | 272 } |
| 272 | 273 |
| 273 ImageData* ImageData::createImageData( | 274 ImageData* ImageData::createImageData( |
| 274 ImageDataArray& data, | 275 ImageDataArray& data, |
| 275 unsigned width, | 276 unsigned width, |
| 276 unsigned height, | 277 unsigned height, |
| 277 const ImageDataColorSettings& colorSettings, | 278 const ImageDataColorSettings& colorSettings, |
| 278 ExceptionState& exceptionState) { | 279 ExceptionState& exceptionState) { |
| 279 DOMArrayBufferView* bufferView = nullptr; | 280 DOMArrayBufferView* bufferView = nullptr; |
| 280 if (data.isUint8ClampedArray()) | 281 if (data.isUint8ClampedArray()) |
| 281 bufferView = data.getAsUint8ClampedArray(); | 282 bufferView = data.getAsUint8ClampedArray().view(); |
| 282 else if (data.isUint16Array()) | 283 else if (data.isUint16Array()) |
| 283 bufferView = data.getAsUint16Array(); | 284 bufferView = data.getAsUint16Array().view(); |
| 284 else if (data.isFloat32Array()) | 285 else if (data.isFloat32Array()) |
| 285 bufferView = data.getAsFloat32Array(); | 286 bufferView = data.getAsFloat32Array().view(); |
| 286 else | 287 else |
| 287 NOTREACHED(); | 288 NOTREACHED(); |
| 288 | 289 |
| 289 if (!ImageData::validateConstructorArguments( | 290 if (!ImageData::validateConstructorArguments( |
| 290 kParamData | kParamWidth | kParamHeight, nullptr, width, height, | 291 kParamData | kParamWidth | kParamHeight, nullptr, width, height, |
| 291 bufferView, &exceptionState)) | 292 bufferView, &exceptionState)) |
| 292 return nullptr; | 293 return nullptr; |
| 293 | 294 |
| 294 return new ImageData(IntSize(width, height), bufferView, &colorSettings, | 295 return new ImageData(IntSize(width, height), bufferView, &colorSettings, |
| 295 kStorageFormatFromBufferType); | 296 kStorageFormatFromBufferType); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 SECURITY_CHECK(static_cast<unsigned>(size.width() * size.height() * 4) <= | 449 SECURITY_CHECK(static_cast<unsigned>(size.width() * size.height() * 4) <= |
| 449 m_dataF32->length()); | 450 m_dataF32->length()); |
| 450 break; | 451 break; |
| 451 | 452 |
| 452 default: | 453 default: |
| 453 NOTREACHED(); | 454 NOTREACHED(); |
| 454 } | 455 } |
| 455 } | 456 } |
| 456 | 457 |
| 457 } // namespace blink | 458 } // namespace blink |
| OLD | NEW |