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

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

Issue 2660393002: Use gfx::ColorSpace instead of SkColorSpace in Blink (Closed)
Patch Set: Rebase (again) Created 3 years, 10 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 return kLinearRGBImageDataColorSpaceName; 364 return kLinearRGBImageDataColorSpaceName;
365 } 365 }
366 NOTREACHED(); 366 NOTREACHED();
367 return String(); 367 return String();
368 } 368 }
369 369
370 sk_sp<SkColorSpace> ImageData::imageDataColorSpaceToSkColorSpace( 370 sk_sp<SkColorSpace> ImageData::imageDataColorSpaceToSkColorSpace(
371 ImageDataColorSpace colorSpace) { 371 ImageDataColorSpace colorSpace) {
372 switch (colorSpace) { 372 switch (colorSpace) {
373 case kLegacyImageDataColorSpace: 373 case kLegacyImageDataColorSpace:
374 return ColorBehavior::globalTargetColorSpace(); 374 return ColorBehavior::globalTargetColorSpace().ToSkColorSpace();
375 case kSRGBImageDataColorSpace: 375 case kSRGBImageDataColorSpace:
376 return SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); 376 return SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
377 case kLinearRGBImageDataColorSpace: 377 case kLinearRGBImageDataColorSpace:
378 return SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); 378 return SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named);
379 } 379 }
380 NOTREACHED(); 380 NOTREACHED();
381 return nullptr; 381 return nullptr;
382 } 382 }
383 383
384 sk_sp<SkColorSpace> ImageData::getSkColorSpace() { 384 sk_sp<SkColorSpace> ImageData::getSkColorSpace() {
385 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() || 385 if (!RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() ||
386 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) 386 !RuntimeEnabledFeatures::colorCorrectRenderingEnabled())
387 return nullptr; 387 return nullptr;
388 return ImageData::imageDataColorSpaceToSkColorSpace(m_colorSpace); 388 return ImageData::imageDataColorSpaceToSkColorSpace(m_colorSpace);
389 } 389 }
390 390
391 ImageData::ImageData(const IntSize& size, 391 ImageData::ImageData(const IntSize& size,
392 DOMUint8ClampedArray* byteArray, 392 DOMUint8ClampedArray* byteArray,
393 String colorSpaceName) 393 String colorSpaceName)
394 : m_size(size), 394 : m_size(size),
395 m_colorSpace(getImageDataColorSpace(colorSpaceName)), 395 m_colorSpace(getImageDataColorSpace(colorSpaceName)),
396 m_data(byteArray) { 396 m_data(byteArray) {
397 DCHECK_GE(size.width(), 0); 397 DCHECK_GE(size.width(), 0);
398 DCHECK_GE(size.height(), 0); 398 DCHECK_GE(size.height(), 0);
399 SECURITY_CHECK(static_cast<unsigned>(size.width() * size.height() * 4) <= 399 SECURITY_CHECK(static_cast<unsigned>(size.width() * size.height() * 4) <=
400 m_data->length()); 400 m_data->length());
401 } 401 }
402 402
403 } // namespace blink 403 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698