| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef CanvasRenderingContext_h | 26 #ifndef CanvasRenderingContext_h |
| 27 #define CanvasRenderingContext_h | 27 #define CanvasRenderingContext_h |
| 28 | 28 |
| 29 #include "core/CoreExport.h" | 29 #include "core/CoreExport.h" |
| 30 #include "core/html/HTMLCanvasElement.h" | 30 #include "core/html/HTMLCanvasElement.h" |
| 31 #include "core/html/canvas/CanvasContextCreationAttributes.h" | 31 #include "core/html/canvas/CanvasContextCreationAttributes.h" |
| 32 #include "core/layout/HitTestCanvasResult.h" | 32 #include "core/layout/HitTestCanvasResult.h" |
| 33 #include "core/offscreencanvas/OffscreenCanvas.h" | 33 #include "core/offscreencanvas/OffscreenCanvas.h" |
| 34 #include "platform/graphics/CanvasColorParams.h" |
| 34 #include "platform/graphics/ColorBehavior.h" | 35 #include "platform/graphics/ColorBehavior.h" |
| 35 #include "platform/wtf/HashSet.h" | 36 #include "platform/wtf/HashSet.h" |
| 36 #include "platform/wtf/Noncopyable.h" | 37 #include "platform/wtf/Noncopyable.h" |
| 37 #include "platform/wtf/text/StringHash.h" | 38 #include "platform/wtf/text/StringHash.h" |
| 38 #include "public/platform/WebThread.h" | 39 #include "public/platform/WebThread.h" |
| 39 #include "third_party/skia/include/core/SkColorSpace.h" | 40 #include "third_party/skia/include/core/SkColorSpace.h" |
| 40 #include "third_party/skia/include/core/SkImageInfo.h" | 41 #include "third_party/skia/include/core/SkImageInfo.h" |
| 41 | 42 |
| 42 namespace blink { | 43 namespace blink { |
| 43 | 44 |
| 44 class CanvasImageSource; | 45 class CanvasImageSource; |
| 45 class HTMLCanvasElement; | 46 class HTMLCanvasElement; |
| 46 class ImageData; | 47 class ImageData; |
| 47 class ImageBitmap; | 48 class ImageBitmap; |
| 48 class WebLayer; | 49 class WebLayer; |
| 49 | 50 |
| 50 enum CanvasColorSpace { | |
| 51 kLegacyCanvasColorSpace, | |
| 52 kSRGBCanvasColorSpace, | |
| 53 kRec2020CanvasColorSpace, | |
| 54 kP3CanvasColorSpace, | |
| 55 }; | |
| 56 | |
| 57 enum CanvasPixelFormat { | |
| 58 kRGBA8CanvasPixelFormat, | |
| 59 kRGB10A2CanvasPixelFormat, | |
| 60 kRGBA12CanvasPixelFormat, | |
| 61 kF16CanvasPixelFormat, | |
| 62 }; | |
| 63 | |
| 64 constexpr const char* kLegacyCanvasColorSpaceName = "legacy-srgb"; | 51 constexpr const char* kLegacyCanvasColorSpaceName = "legacy-srgb"; |
| 65 constexpr const char* kSRGBCanvasColorSpaceName = "srgb"; | 52 constexpr const char* kSRGBCanvasColorSpaceName = "srgb"; |
| 66 constexpr const char* kRec2020CanvasColorSpaceName = "rec2020"; | 53 constexpr const char* kRec2020CanvasColorSpaceName = "rec2020"; |
| 67 constexpr const char* kP3CanvasColorSpaceName = "p3"; | 54 constexpr const char* kP3CanvasColorSpaceName = "p3"; |
| 68 | 55 |
| 69 constexpr const char* kRGBA8CanvasPixelFormatName = "8-8-8-8"; | 56 constexpr const char* kRGBA8CanvasPixelFormatName = "8-8-8-8"; |
| 70 constexpr const char* kRGB10A2CanvasPixelFormatName = "10-10-10-2"; | 57 constexpr const char* kRGB10A2CanvasPixelFormatName = "10-10-10-2"; |
| 71 constexpr const char* kRGBA12CanvasPixelFormatName = "12-12-12-12"; | 58 constexpr const char* kRGBA12CanvasPixelFormatName = "12-12-12-12"; |
| 72 constexpr const char* kF16CanvasPixelFormatName = "float16"; | 59 constexpr const char* kF16CanvasPixelFormatName = "float16"; |
| 73 | 60 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 95 kContextWebgl2 = 4, | 82 kContextWebgl2 = 4, |
| 96 kContextImageBitmap = 5, | 83 kContextImageBitmap = 5, |
| 97 kContextTypeCount, | 84 kContextTypeCount, |
| 98 }; | 85 }; |
| 99 | 86 |
| 100 static ContextType ContextTypeFromId(const String& id); | 87 static ContextType ContextTypeFromId(const String& id); |
| 101 static ContextType ResolveContextTypeAliases(ContextType); | 88 static ContextType ResolveContextTypeAliases(ContextType); |
| 102 | 89 |
| 103 HTMLCanvasElement* canvas() const { return canvas_; } | 90 HTMLCanvasElement* canvas() const { return canvas_; } |
| 104 | 91 |
| 105 CanvasColorSpace ColorSpace() const { return color_space_; }; | 92 CanvasColorSpace ColorSpace() const; |
| 106 WTF::String ColorSpaceAsString() const; | 93 WTF::String ColorSpaceAsString() const; |
| 107 CanvasPixelFormat PixelFormat() const { return pixel_format_; }; | 94 CanvasPixelFormat PixelFormat() const; |
| 108 WTF::String PixelFormatAsString() const; | 95 WTF::String PixelFormatAsString() const; |
| 109 bool LinearPixelMath() const { return linear_pixel_math_; }; | 96 bool LinearPixelMath() const; |
| 110 | 97 |
| 111 // The color space in which the the content should be interpreted by the | 98 // The color space in which the the content should be interpreted by the |
| 112 // compositor. This is always defined. | 99 // compositor. This is always defined. |
| 113 gfx::ColorSpace GfxColorSpace() const; | 100 gfx::ColorSpace GfxColorSpace() const; |
| 114 // The color space that should be used for SkSurface creation. This may | 101 // The color space that should be used for SkSurface creation. This may |
| 115 // be nullptr. | 102 // be nullptr. |
| 116 sk_sp<SkColorSpace> SkSurfaceColorSpace() const; | 103 sk_sp<SkColorSpace> SkSurfaceColorSpace() const; |
| 117 SkColorType ColorType() const; | 104 SkColorType ColorType() const; |
| 118 ColorBehavior ColorBehaviorForMediaDrawnToCanvas() const; | 105 ColorBehavior ColorBehaviorForMediaDrawnToCanvas() const; |
| 119 bool SkSurfacesUseColorSpace() const; | 106 bool SkSurfacesUseColorSpace() const; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 DECLARE_VIRTUAL_TRACE(); | 212 DECLARE_VIRTUAL_TRACE(); |
| 226 virtual void Stop() = 0; | 213 virtual void Stop() = 0; |
| 227 | 214 |
| 228 private: | 215 private: |
| 229 void Dispose(); | 216 void Dispose(); |
| 230 | 217 |
| 231 Member<HTMLCanvasElement> canvas_; | 218 Member<HTMLCanvasElement> canvas_; |
| 232 Member<OffscreenCanvas> offscreen_canvas_; | 219 Member<OffscreenCanvas> offscreen_canvas_; |
| 233 HashSet<String> clean_urls_; | 220 HashSet<String> clean_urls_; |
| 234 HashSet<String> dirty_urls_; | 221 HashSet<String> dirty_urls_; |
| 235 CanvasColorSpace color_space_; | 222 CanvasColorParams color_params_; |
| 236 CanvasPixelFormat pixel_format_; | |
| 237 bool linear_pixel_math_ = false; | |
| 238 CanvasContextCreationAttributes creation_attributes_; | 223 CanvasContextCreationAttributes creation_attributes_; |
| 239 bool finalize_frame_scheduled_ = false; | 224 bool finalize_frame_scheduled_ = false; |
| 240 }; | 225 }; |
| 241 | 226 |
| 242 } // namespace blink | 227 } // namespace blink |
| 243 | 228 |
| 244 #endif | 229 #endif |
| OLD | NEW |