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

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

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
Index: third_party/WebKit/Source/platform/graphics/CanvasColorParams.h
diff --git a/third_party/WebKit/Source/platform/graphics/CanvasColorParams.h b/third_party/WebKit/Source/platform/graphics/CanvasColorParams.h
new file mode 100644
index 0000000000000000000000000000000000000000..daf034af488f2357efa27308fe6833a770fc0c95
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/CanvasColorParams.h
@@ -0,0 +1,59 @@
+// 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.
+
+#ifndef CanvasColorParams_h
+#define CanvasColorParams_h
+
+#include "platform/PlatformExport.h"
+#include "third_party/skia/include/core/SkColorSpace.h"
+#include "third_party/skia/include/core/SkImageInfo.h"
+
+namespace gfx {
+class ColorSpace;
+}
+
+namespace blink {
+
+enum CanvasColorSpace {
+ kLegacyCanvasColorSpace,
+ kSRGBCanvasColorSpace,
+ kRec2020CanvasColorSpace,
+ kP3CanvasColorSpace,
+};
+
+enum CanvasPixelFormat {
+ kRGBA8CanvasPixelFormat,
+ kRGB10A2CanvasPixelFormat,
+ kRGBA12CanvasPixelFormat,
+ kF16CanvasPixelFormat,
+};
+
+class PLATFORM_EXPORT CanvasColorParams {
+ public:
+ CanvasColorParams(CanvasColorSpace, CanvasPixelFormat);
+ CanvasColorSpace color_space() const { return color_space_; }
+ CanvasPixelFormat pixel_format() const { return pixel_format_; }
+
+ // The SkColorSpace to use in the SkImageInfo for allocated SkSurfaces. This
+ // is nullptr in legacy rendering mode.
+ sk_sp<SkColorSpace> GetSkColorSpaceForSkSurfaces() const;
+
+ // The pixel format to use for allocating SkSurfaces.
+ SkColorType GetSkColorType() const;
+
+ // The color space to use for compositing.
+ gfx::ColorSpace GetGfxColorSpace() const;
+
+ // This matches CanvasRenderingContext::LinearPixelMath, and is true only when
+ // the pixel format is half-float linear.
+ bool LinearPixelMath() const;
+
+ private:
+ CanvasColorSpace color_space_ = kLegacyCanvasColorSpace;
+ CanvasPixelFormat pixel_format_ = kRGBA8CanvasPixelFormat;
+};
+
+} // namespace blink
+
+#endif // CanvasColorParams_h
« no previous file with comments | « third_party/WebKit/Source/platform/BUILD.gn ('k') | third_party/WebKit/Source/platform/graphics/CanvasColorParams.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698