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 21 matching lines...) Expand all Loading... |
32 #include "public/platform/Platform.h" | 32 #include "public/platform/Platform.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 CanvasRenderingContext::CanvasRenderingContext( | 36 CanvasRenderingContext::CanvasRenderingContext( |
37 CanvasRenderingContextHost* host, | 37 CanvasRenderingContextHost* host, |
38 const CanvasContextCreationAttributes& attrs) | 38 const CanvasContextCreationAttributes& attrs) |
39 : host_(host), | 39 : host_(host), |
40 color_params_(kLegacyCanvasColorSpace, kRGBA8CanvasPixelFormat), | 40 color_params_(kLegacyCanvasColorSpace, kRGBA8CanvasPixelFormat), |
41 creation_attributes_(attrs) { | 41 creation_attributes_(attrs) { |
42 if (RuntimeEnabledFeatures::experimentalCanvasFeaturesEnabled() && | 42 if (RuntimeEnabledFeatures::colorCanvasExtensionsEnabled()) { |
43 RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) { | |
44 // Set the default color space to SRGB and continue | 43 // Set the default color space to SRGB and continue |
45 CanvasColorSpace color_space = kSRGBCanvasColorSpace; | 44 CanvasColorSpace color_space = kSRGBCanvasColorSpace; |
46 if (creation_attributes_.colorSpace() == kRec2020CanvasColorSpaceName) | 45 if (creation_attributes_.colorSpace() == kRec2020CanvasColorSpaceName) |
47 color_space = kRec2020CanvasColorSpace; | 46 color_space = kRec2020CanvasColorSpace; |
48 else if (creation_attributes_.colorSpace() == kP3CanvasColorSpaceName) | 47 else if (creation_attributes_.colorSpace() == kP3CanvasColorSpaceName) |
49 color_space = kP3CanvasColorSpace; | 48 color_space = kP3CanvasColorSpace; |
50 | 49 |
51 // For now, we only support RGBA8 (for SRGB) and F16 (for all). Everything | 50 // For now, we only support RGBA8 (for SRGB) and F16 (for all). Everything |
52 // else falls back to SRGB + RGBA8. | 51 // else falls back to SRGB + RGBA8. |
53 CanvasPixelFormat pixel_format = kRGBA8CanvasPixelFormat; | 52 CanvasPixelFormat pixel_format = kRGBA8CanvasPixelFormat; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 return kRGB10A2CanvasPixelFormatName; | 90 return kRGB10A2CanvasPixelFormatName; |
92 case kRGBA12CanvasPixelFormat: | 91 case kRGBA12CanvasPixelFormat: |
93 return kRGBA12CanvasPixelFormatName; | 92 return kRGBA12CanvasPixelFormatName; |
94 case kF16CanvasPixelFormat: | 93 case kF16CanvasPixelFormat: |
95 return kF16CanvasPixelFormatName; | 94 return kF16CanvasPixelFormatName; |
96 }; | 95 }; |
97 CHECK(false); | 96 CHECK(false); |
98 return ""; | 97 return ""; |
99 } | 98 } |
100 | 99 |
101 ColorBehavior CanvasRenderingContext::ColorBehaviorForMediaDrawnToCanvas() | |
102 const { | |
103 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) | |
104 return ColorBehavior::TransformTo(color_params_.GetGfxColorSpace()); | |
105 return ColorBehavior::TransformToGlobalTarget(); | |
106 } | |
107 | |
108 void CanvasRenderingContext::Dispose() { | 100 void CanvasRenderingContext::Dispose() { |
109 if (finalize_frame_scheduled_) { | 101 if (finalize_frame_scheduled_) { |
110 Platform::Current()->CurrentThread()->RemoveTaskObserver(this); | 102 Platform::Current()->CurrentThread()->RemoveTaskObserver(this); |
111 } | 103 } |
112 | 104 |
113 // HTMLCanvasElement and CanvasRenderingContext have a circular reference. | 105 // HTMLCanvasElement and CanvasRenderingContext have a circular reference. |
114 // When the pair is no longer reachable, their destruction order is non- | 106 // When the pair is no longer reachable, their destruction order is non- |
115 // deterministic, so the first of the two to be destroyed needs to notify | 107 // deterministic, so the first of the two to be destroyed needs to notify |
116 // the other in order to break the circular reference. This is to avoid | 108 // the other in order to break the circular reference. This is to avoid |
117 // an error when CanvasRenderingContext::didProcessTask() is invoked | 109 // an error when CanvasRenderingContext::didProcessTask() is invoked |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 clean_urls_.insert(source_url.GetString()); | 190 clean_urls_.insert(source_url.GetString()); |
199 } | 191 } |
200 return taint_origin; | 192 return taint_origin; |
201 } | 193 } |
202 | 194 |
203 DEFINE_TRACE(CanvasRenderingContext) { | 195 DEFINE_TRACE(CanvasRenderingContext) { |
204 visitor->Trace(host_); | 196 visitor->Trace(host_); |
205 } | 197 } |
206 | 198 |
207 } // namespace blink | 199 } // namespace blink |
OLD | NEW |