| Index: third_party/WebKit/Source/platform/graphics/CanvasColorParams.cpp
|
| diff --git a/third_party/WebKit/Source/platform/graphics/CanvasColorParams.cpp b/third_party/WebKit/Source/platform/graphics/CanvasColorParams.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ea86467666e551f63286f205e2493ce5d5471399
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/platform/graphics/CanvasColorParams.cpp
|
| @@ -0,0 +1,49 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "platform/graphics/CanvasColorParams.h"
|
| +
|
| +#include "ui/gfx/color_space.h"
|
| +
|
| +namespace blink {
|
| +
|
| +CanvasColorParams::CanvasColorParams(CanvasColorSpace color_space,
|
| + CanvasPixelFormat pixel_format)
|
| + : color_space_(color_space), pixel_format_(pixel_format) {}
|
| +
|
| +sk_sp<SkColorSpace> CanvasColorParams::GetSkColorSpaceForSkSurfaces() const {
|
| + if (color_space_ == kLegacyCanvasColorSpace)
|
| + return nullptr;
|
| + return GetGfxColorSpace().ToSkColorSpace();
|
| +}
|
| +
|
| +SkColorType CanvasColorParams::GetSkColorType() const {
|
| + if (pixel_format_ == kF16CanvasPixelFormat)
|
| + return kRGBA_F16_SkColorType;
|
| + return kN32_SkColorType;
|
| +}
|
| +
|
| +gfx::ColorSpace CanvasColorParams::GetGfxColorSpace() const {
|
| + switch (color_space_) {
|
| + case kLegacyCanvasColorSpace:
|
| + return gfx::ColorSpace::CreateSRGB();
|
| + case kSRGBCanvasColorSpace:
|
| + if (pixel_format_ == kF16CanvasPixelFormat)
|
| + return gfx::ColorSpace::CreateSCRGBLinear();
|
| + return gfx::ColorSpace::CreateSRGB();
|
| + case kRec2020CanvasColorSpace:
|
| + return gfx::ColorSpace(gfx::ColorSpace::PrimaryID::BT2020,
|
| + gfx::ColorSpace::TransferID::IEC61966_2_1);
|
| + case kP3CanvasColorSpace:
|
| + return gfx::ColorSpace(gfx::ColorSpace::PrimaryID::SMPTEST432_1,
|
| + gfx::ColorSpace::TransferID::IEC61966_2_1);
|
| + }
|
| + return gfx::ColorSpace();
|
| +}
|
| +
|
| +bool CanvasColorParams::LinearPixelMath() const {
|
| + return pixel_format_ == kF16CanvasPixelFormat;
|
| +}
|
| +
|
| +} // namespace blink
|
|
|