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

Side by Side Diff: third_party/WebKit/Source/core/html/canvas/CanvasRenderingContext.cpp

Issue 2825183002: Plumb CanvasColorParams to canvas image classes (Closed)
Patch Set: Require both runtime flags 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 unified diff | Download patch
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 pixel_format = kRGBA8CanvasPixelFormat; 60 pixel_format = kRGBA8CanvasPixelFormat;
61 } 61 }
62 62
63 color_params_ = CanvasColorParams(color_space, pixel_format); 63 color_params_ = CanvasColorParams(color_space, pixel_format);
64 } 64 }
65 65
66 // Make m_creationAttributes reflect the effective colorSpace, pixelFormat and 66 // Make m_creationAttributes reflect the effective colorSpace, pixelFormat and
67 // linearPixelMath rather than the requested one. 67 // linearPixelMath rather than the requested one.
68 creation_attributes_.setColorSpace(ColorSpaceAsString()); 68 creation_attributes_.setColorSpace(ColorSpaceAsString());
69 creation_attributes_.setPixelFormat(PixelFormatAsString()); 69 creation_attributes_.setPixelFormat(PixelFormatAsString());
70 creation_attributes_.setLinearPixelMath(LinearPixelMath()); 70 creation_attributes_.setLinearPixelMath(color_params_.LinearPixelMath());
71 } 71 }
72 72
73 WTF::String CanvasRenderingContext::ColorSpaceAsString() const { 73 WTF::String CanvasRenderingContext::ColorSpaceAsString() const {
74 switch (color_params_.color_space()) { 74 switch (color_params_.color_space()) {
75 case kLegacyCanvasColorSpace: 75 case kLegacyCanvasColorSpace:
76 return kLegacyCanvasColorSpaceName; 76 return kLegacyCanvasColorSpaceName;
77 case kSRGBCanvasColorSpace: 77 case kSRGBCanvasColorSpace:
78 return kSRGBCanvasColorSpaceName; 78 return kSRGBCanvasColorSpaceName;
79 case kRec2020CanvasColorSpace: 79 case kRec2020CanvasColorSpace:
80 return kRec2020CanvasColorSpaceName; 80 return kRec2020CanvasColorSpaceName;
(...skipping 12 matching lines...) Expand all
93 return kRGB10A2CanvasPixelFormatName; 93 return kRGB10A2CanvasPixelFormatName;
94 case kRGBA12CanvasPixelFormat: 94 case kRGBA12CanvasPixelFormat:
95 return kRGBA12CanvasPixelFormatName; 95 return kRGBA12CanvasPixelFormatName;
96 case kF16CanvasPixelFormat: 96 case kF16CanvasPixelFormat:
97 return kF16CanvasPixelFormatName; 97 return kF16CanvasPixelFormatName;
98 }; 98 };
99 CHECK(false); 99 CHECK(false);
100 return ""; 100 return "";
101 } 101 }
102 102
103 gfx::ColorSpace CanvasRenderingContext::GfxColorSpace() const {
104 return color_params_.GetGfxColorSpace();
105 }
106
107 sk_sp<SkColorSpace> CanvasRenderingContext::SkSurfaceColorSpace() const {
108 return color_params_.GetSkColorSpaceForSkSurfaces();
109 }
110
111 bool CanvasRenderingContext::SkSurfacesUseColorSpace() const {
112 return color_params_.GetSkColorSpaceForSkSurfaces();
113 }
114
115 bool CanvasRenderingContext::LinearPixelMath() const {
116 return color_params_.LinearPixelMath();
117 }
118
119 ColorBehavior CanvasRenderingContext::ColorBehaviorForMediaDrawnToCanvas() 103 ColorBehavior CanvasRenderingContext::ColorBehaviorForMediaDrawnToCanvas()
120 const { 104 const {
121 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) 105 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled())
122 return ColorBehavior::TransformTo(GfxColorSpace()); 106 return ColorBehavior::TransformTo(color_params_.GetGfxColorSpace());
123 return ColorBehavior::TransformToGlobalTarget(); 107 return ColorBehavior::TransformToGlobalTarget();
124 } 108 }
125 109
126 CanvasColorSpace CanvasRenderingContext::ColorSpace() const {
127 return color_params_.color_space();
128 }
129
130 SkColorType CanvasRenderingContext::ColorType() const {
131 return color_params_.GetSkColorType();
132 }
133
134 void CanvasRenderingContext::Dispose() { 110 void CanvasRenderingContext::Dispose() {
135 if (finalize_frame_scheduled_) { 111 if (finalize_frame_scheduled_) {
136 Platform::Current()->CurrentThread()->RemoveTaskObserver(this); 112 Platform::Current()->CurrentThread()->RemoveTaskObserver(this);
137 } 113 }
138 114
139 // HTMLCanvasElement and CanvasRenderingContext have a circular reference. 115 // HTMLCanvasElement and CanvasRenderingContext have a circular reference.
140 // When the pair is no longer reachable, their destruction order is non- 116 // When the pair is no longer reachable, their destruction order is non-
141 // deterministic, so the first of the two to be destroyed needs to notify 117 // deterministic, so the first of the two to be destroyed needs to notify
142 // the other in order to break the circular reference. This is to avoid 118 // the other in order to break the circular reference. This is to avoid
143 // an error when CanvasRenderingContext::didProcessTask() is invoked 119 // an error when CanvasRenderingContext::didProcessTask() is invoked
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 206 }
231 return taint_origin; 207 return taint_origin;
232 } 208 }
233 209
234 DEFINE_TRACE(CanvasRenderingContext) { 210 DEFINE_TRACE(CanvasRenderingContext) {
235 visitor->Trace(canvas_); 211 visitor->Trace(canvas_);
236 visitor->Trace(offscreen_canvas_); 212 visitor->Trace(offscreen_canvas_);
237 } 213 }
238 214
239 } // namespace blink 215 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698