Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: third_party/WebKit/Source/core/html/ImageData.cpp

Issue 2797213002: Fix BaseRenderingContext2D create/put/get-ImageData() for color managed canvas (Closed)
Patch Set: Rebaseline Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 unsigned height, 269 unsigned height,
270 ExceptionState& exception_state) { 270 ExceptionState& exception_state) {
271 if (!ImageData::ValidateConstructorArguments( 271 if (!ImageData::ValidateConstructorArguments(
272 kParamData | kParamWidth | kParamHeight, nullptr, width, height, 272 kParamData | kParamWidth | kParamHeight, nullptr, width, height,
273 data.View(), nullptr, &exception_state)) 273 data.View(), nullptr, &exception_state))
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() ||
285 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled())
286 return nullptr;
287
284 if (!ImageData::ValidateConstructorArguments( 288 if (!ImageData::ValidateConstructorArguments(
285 kParamWidth | kParamHeight, nullptr, width, height, nullptr, 289 kParamWidth | kParamHeight, nullptr, width, height, nullptr,
286 &color_settings, &exception_state)) 290 &color_settings, &exception_state))
287 return nullptr; 291 return nullptr;
288 292
289 ImageDataStorageFormat storage_format = 293 ImageDataStorageFormat storage_format =
290 ImageData::GetImageDataStorageFormat(color_settings.storageFormat()); 294 ImageData::GetImageDataStorageFormat(color_settings.storageFormat());
291 DOMArrayBufferView* buffer_view = AllocateAndValidateDataArray( 295 DOMArrayBufferView* buffer_view = AllocateAndValidateDataArray(
292 4 * width * height, storage_format, &exception_state); 296 4 * width * height, storage_format, &exception_state);
293 297
294 if (!buffer_view) 298 if (!buffer_view)
295 return nullptr; 299 return nullptr;
296 300
297 return new ImageData(IntSize(width, height), buffer_view, &color_settings); 301 return new ImageData(IntSize(width, height), buffer_view, &color_settings);
298 } 302 }
299 303
300 ImageData* ImageData::createImageData(ImageDataArray& data, 304 ImageData* ImageData::CreateImageData(ImageDataArray& data,
301 unsigned width, 305 unsigned width,
302 unsigned height, 306 unsigned height,
303 ImageDataColorSettings& color_settings, 307 ImageDataColorSettings& color_settings,
304 ExceptionState& exception_state) { 308 ExceptionState& exception_state) {
309 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() ||
310 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled())
311 return nullptr;
312
305 DOMArrayBufferView* buffer_view = nullptr; 313 DOMArrayBufferView* buffer_view = nullptr;
314
306 // When pixels data is provided, we need to override the storage format of 315 // When pixels data is provided, we need to override the storage format of
307 // ImageDataColorSettings with the one that matches the data type of the 316 // ImageDataColorSettings with the one that matches the data type of the
308 // pixels. 317 // pixels.
309 String storage_format_name; 318 String storage_format_name;
310 319
311 if (data.isUint8ClampedArray()) { 320 if (data.isUint8ClampedArray()) {
312 buffer_view = data.getAsUint8ClampedArray().View(); 321 buffer_view = data.getAsUint8ClampedArray().View();
313 storage_format_name = kUint8ClampedArrayStorageFormatName; 322 storage_format_name = kUint8ClampedArrayStorageFormatName;
314 } else if (data.isUint16Array()) { 323 } else if (data.isUint16Array()) {
315 buffer_view = data.getAsUint16Array().View(); 324 buffer_view = data.getAsUint16Array().View();
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 NOTREACHED(); 576 NOTREACHED();
568 } 577 }
569 break; 578 break;
570 579
571 default: 580 default:
572 NOTREACHED(); 581 NOTREACHED();
573 } 582 }
574 return nullptr; 583 return nullptr;
575 } 584 }
576 585
586 DOMArrayBufferBase* ImageData::BufferBase() const {
587 if (data_)
588 return data_->BufferBase();
589 if (data_u16_)
590 return data_u16_->BufferBase();
591 if (data_f32_)
592 return data_f32_->BufferBase();
593 return nullptr;
594 }
595
577 // For ImageData, the color space is only specified by color settings. 596 // For ImageData, the color space is only specified by color settings.
578 // It cannot have a SkColorSpace. This doesn't mean anything. Fix this. 597 // It cannot have a SkColorSpace. This doesn't mean anything. Fix this.
579 sk_sp<SkColorSpace> ImageData::GetSkColorSpace() { 598 sk_sp<SkColorSpace> ImageData::GetSkColorSpace() {
580 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() || 599 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() ||
581 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) 600 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled())
582 return nullptr; 601 return nullptr;
583 602
584 return SkColorSpace::MakeSRGB(); 603 return SkColorSpace::MakeSRGB();
585 } 604 }
586 605
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 SECURITY_CHECK(static_cast<unsigned>(size.Width() * size.Height() * 4) <= 779 SECURITY_CHECK(static_cast<unsigned>(size.Width() * size.Height() * 4) <=
761 data_f32_->length()); 780 data_f32_->length());
762 break; 781 break;
763 782
764 default: 783 default:
765 NOTREACHED(); 784 NOTREACHED();
766 } 785 }
767 } 786 }
768 787
769 } // namespace blink 788 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/ImageData.h ('k') | third_party/WebKit/Source/core/html/ImageData.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698