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

Unified Diff: third_party/WebKit/Source/platform/graphics/CanvasColorParams.cpp

Issue 2823063002: Consolidate canvas color params into a single class (Closed)
Patch Set: Fix compile 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/CanvasColorParams.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/CanvasColorParams.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698